share session between drivers

179 Aufrufe
Direkt zur ersten ungelesenen Nachricht

dgenki

ungelesen,
27.06.2011, 06:45:2527.06.11
an Selenium Users
Hi, there. I'm wondering if there is a way to attach a htmlUnitDriver
to a firefoxDriver. I want to let the user guide the application
visually through firefox until they perform a search. From that point
I want to change to htmlUnit as I don't want to display what is going
on in the browser. Is there any way to do this?

Thank you in advance for your help.

Luke Inman-Semerau

ungelesen,
27.06.2011, 12:43:5827.06.11
an seleniu...@googlegroups.com
By shared session I'm guessing you mean within context of that website (after the user logs in?) Which would probably mean the site is using cookies to track the users session...

If that assumption is correct then you can get the cookie from the firefox driver and set it in the HtmlUnit driver:

WebDriver ff = new FirefoxDriver();
WebDriver hu = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);

// do the firefox stuff
...

// copy the cookies to htmlUnit driver
for (Cookie c : ff.manage().getCookies()) {
hu.manage().addCookie(c);
}

// do the html unit stuff
....


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


dgenki

ungelesen,
27.06.2011, 15:18:3827.06.11
an Selenium Users
Your assumptions are right, Luke. I tried what you suggested and it's
working now. Just a hint for users: I had to open a page with
htmlUnitDriver in the same domain as firefoxDriver to comply with the
cookies security policy. Thank you very much for your help.

On Jun 27, 5:43 pm, Luke Inman-Semerau <luke.seme...@gmail.com> wrote:
> By shared session I'm guessing you mean within context of that website
> (after the user logs in?) Which would probably mean the site is using
> cookies to track the users session...
>
> If that assumption is correct then you can get the cookie from the firefox
> driver and set it in the HtmlUnit driver:
>
> WebDriver ff = new FirefoxDriver();
> WebDriver hu = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
>
> // do the firefox stuff
> ...
>
> // copy the cookies to htmlUnit driver
> for (Cookie c : ff.manage().getCookies()) {
> hu.manage().addCookie(c);
>
> }
>
> // do the html unit stuff
> ....
>

Syagin Kumar

ungelesen,
24.08.2016, 07:59:5624.08.16
an Selenium Users
Hi Luke,

Your idea is good, but when I trying with chrome, it is asking to set the setJavascriptEnabled"
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten