1

I'm using Ruby + Watir + Cucumber for test automation. At the start of each Feature, I launch a new browser, and at the end I generally leave the browser running for the time being (while I work through developing my scenarios).

Sometimes when I'm ironing the kinks out of my Step Definitions, it would be really handy if I could connect to an active Watir browser session from IRB (Interactive Ruby Shell) in order to try some commands or check some attributes within the webpage in it's current state.

Is there a way I can connect to an existing browser via IRB that was launched via Cucumber? e.g. by using the name or hex id attributes?

Hoppertron
  • 166
  • 3
  • 9
  • 1
    Possible duplicate of [Can Selenium webdriver attach to already open browser window?](http://stackoverflow.com/questions/15960692/can-selenium-webdriver-attach-to-already-open-browser-window). Note that Watir-Webdriver is simply a wrapper around Selenium-Webdriver. As Selenium has/will not add this functionality, it will not be possible with Watir-Webdriver. – Justin Ko Feb 19 '15 at 17:13

1 Answers1

2

There are 2 potential dimensions to this question.

First, can watir-webdriver connect to an existing web browser process that it did not spawn? No, this is not currently possible.

Second, can multiple ruby processes connect to the same watir-webdriver? Technically it should be possible, but I do not believe that Watir supports it. Multiple ruby processes would have to connect to the watir-webdriver via the same port. A quick look at the watir browser.rb source does not show any evidence of this functionality being supported.

Mike S
  • 11,329
  • 6
  • 41
  • 76
  • Thanks for the comprehensive answer. I must be going mad as I could have sworn I did this in Selenium a while back but must have imagined it. – Hoppertron Feb 20 '15 at 00:27
  • 2
    It is possible in classic watir where the browser is IE and we are not driving the browser via webdriver. An .attach method is supported in that case. But as explained, not possible with webdriver driving the browser. – Chuck van der Linden Feb 20 '15 at 04:48