How to use existing browser session for webdriver to automate

5,278 views
Skip to first unread message

rocky

unread,
Apr 25, 2016, 7:12:29 AM4/25/16
to webdriver
Hi, I am using Selenium with C# . I want to use the existing IE open browser session and pass it to webdriver , so that it can work on taking the existing browser session and perform action on the opened UI in browser.

As in my AUT , it takes lot of time to reach to the page where I am working, so instead of initializing webdriver and opeing AUT in  browser (IE) every time for debugging, I want the test to take action on opened AUT in IE browser. 

Pls help with the code in C# Selenium  to use existing Internet Explore browser session .



Thanks,
Rocky

⇜Krishnan Mahadevan⇝

unread,
Apr 25, 2016, 7:15:04 AM4/25/16
to webdriver
Rakesh,
(To the best of my knowledge) Short answer : You cannot do this in Selenium. Selenium would know how to interact with a browser if and only if it spawned it. It doesn't know how to interact with an existing browser.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at https://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

mir saadat Ali Hashmi

unread,
May 27, 2016, 8:58:22 AM5/27/16
to webdriver
Hey,

Sorry for a late reply.
May be you can try cookies for doing the same. For example if your scenario has user login transaction, then login once, store those cookies, close the browser, then set those cookies back on browser and directly navigate to your page, where your test should be executing.
Hope this idea helps.

-Saadat

David

unread,
May 28, 2016, 2:04:23 PM5/28/16
to webdriver
For cookies, option, unless you don't know what the cookie names & values will be, the better option is to predefine/statically define them and create them at runtime after you've loaded a page on the site, rather than as Saadat suggest of opening browser to save a copy of cookies then load back in a new browser session.

For session cookies whose value is dynamic, first use an HTTP request library/code (in C#/.NET) to establish a session (non-Selenium) and set things up, your preferences, system state, then set that cookie in Selenium browser session (it would overwrite the cookie if it exists) so that it will use that session. It's faster this way than using browser to setup session, save session value/ID then reload in subsequent new browser sessions, unless you had to do this browser-side only.

Also for IE, what you originally wanted might be achievable with WatiN instead of Selenium.

AVI

unread,
Jun 2, 2016, 9:19:52 AM6/2/16
to webdriver
You may try trick given in the link below . I remember using this with FF in past.

http://www.binaryclips.com/2016/03/selenium-web-driver-in-c-how-to.html?m=1

Reply all
Reply to author
Forward
0 new messages