Attaching WebDriver to existing browser

2,612 views
Skip to first unread message

rajesh thirumalasetti

unread,
Feb 21, 2017, 11:08:39 AM2/21/17
to Selenium Users
We have an automation scenario where click on a window application button launches browser. The automation need to act upon this browser. Since this is not launched by Webdriver, I could not find a way to this browser. I have searched a lot in internet but nothing solved my problem.

I would request you to kindly help me on the same ASAP

Thanks and Regards,

Rajesh T

Titus Fortner

unread,
Feb 21, 2017, 12:10:15 PM2/21/17
to seleniu...@googlegroups.com
That use case is explicitly not supported by Selenium. In order for a driver to interact with a browser, the driver has to be the thing that created the session/opened the browser in the first place.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1b3376df-ca34-49c3-9019-d5c20d286734%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anand Somani

unread,
Feb 21, 2017, 12:43:40 PM2/21/17
to seleniu...@googlegroups.com
Not supported by Selenium. Limitation of Selenium. :(

Thanks & Regards,
Anand Somani |
Skype ID: anand.somani
LinkedIn Profile : https://www.linkedin.com/in/somanianands
Visit Blogs: http://seleniumtestingguide.blogspot.in/

On 21 February 2017 at 17:09, Titus Fortner <titusf...@gmail.com> wrote:
That use case is explicitly not supported by Selenium. In order for a driver to interact with a browser, the driver has to be the thing that created the session/opened the browser in the first place.
On Tue, Feb 21, 2017 at 7:11 AM, rajesh thirumalasetti <rj1...@gmail.com> wrote:
We have an automation scenario where click on a window application button launches browser. The automation need to act upon this browser. Since this is not launched by Webdriver, I could not find a way to this browser. I have searched a lot in internet but nothing solved my problem.

I would request you to kindly help me on the same ASAP

Thanks and Regards,

Rajesh T

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Andreas Tolfsen

unread,
Feb 23, 2017, 6:31:16 PM2/23/17
to seleniu...@googlegroups.com
Also sprach Titus Fortner <titusf...@gmail.com>:

> That use case is explicitly not supported by Selenium. In order for a
> driver to interact with a browser, the driver has to be the thing
> that created the session/opened the browser in the first place.

It might not be explicitly supported by Selenium, but individual
drivers do support this.

The first driver that made it possible to attach to an existing browser
was OperaDriver for the Presto-based Operas. You would spin up the
driver, navigate the browser to opera:debug and hit a ‘Connect’ button
on that page. This worked because the driver filled the role of the
server, and the browser effectively acted as the client.

Marionette and geckodriver in Firefox also lets you connect to an
existing browser instance, _provided_ you have started Firefox with the
--marionette flag already:

% geckodriver --connect-existing

This is slightly less flexible than the OperaDriver solution, but this
tells geckodriver to connect to the Marionette remote control server
that is already running inside Firefox.

Mike Hetzer

unread,
Apr 19, 2018, 10:34:29 PM4/19/18
to Selenium Users
Easiest, perhaps only way to do what you need to do would be to:
1. Identify the browser window that is spawned using Windows Automation.
2. Grab the URL string from the navigation bar.
3. Spin up a webdriver using that stored string.

We've had to do this for a couple projects.

David

unread,
Apr 20, 2018, 4:40:41 PM4/20/18
to Selenium Users
Can you clarify/elaborate on this? This sounds like step 3 is using value taken from step 2, and step 2 sounds like grab URL in nav bar of browser window found in step 1. Overall this sounds like spin up a separate browser via WebDriver and go to same URL of the browser found in step 1, but we leave browser in step 1 alone/orphaned for the rest of the browser automation as you don't (or can't) specifically connect to it as an existing WebDriver browser session.

Naveen Kumar

unread,
Apr 20, 2018, 9:18:58 PM4/20/18
to seleniu...@googlegroups.com
Can you please elaborate this, in knowledge selenium can't attached with existing browser (already opened before selenium web driver start).

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Snehal Biche

unread,
Apr 20, 2018, 10:34:25 PM4/20/18
to Selenium Users
I have never tried but check winium driver if this driver helps you. This is for windows UI

Mike Hetzer

unread,
Apr 22, 2018, 3:03:35 AM4/22/18
to Selenium Users
Pretty much yeah.

In order to find this with Windows Automation, you would have likely already found the Process ID or the browser window - with this information you can kill the unused/orphaned browser window.

If you are using java frameworks - you'll likely have to use winium or some other library.

C# projects can use Windows Automation, but I prefer the TestStack: White project
Reply all
Reply to author
Forward
0 new messages