2

There is an easy way to get the Sauce Labs job ID when using Selenium-Webdriver as outlined at the bottom of this page.

Is there a similar method for Watir-Webdriver?

pjd
  • 1,163
  • 8
  • 17
user3250926
  • 127
  • 1
  • 2
  • 7

1 Answers1

4

The driver session ID is not directly exposed via the Watir API. However, you can just call the same method directly against the underlying driver object:

Assuming browser is your Watir::Browser instance:

browser.driver.session_id
Justin Ko
  • 46,526
  • 5
  • 91
  • 101
  • I was working on this yesterday and tried that. I get `NoMethodError: undefined method `session_id' for #` with your solution (using Chrome). When I type `browser.driver.session_storage` I see `@session_id` in there, but I couldn't figure out how to extract it. – pjd Mar 24 '16 at 13:24
  • I should also mention that I was using a page from your website as my guide yesterday (https://jkotests.wordpress.com/2013/06/13/accessing-selenium-webdriver-from-watir-webdriver/). Thanks! – pjd Mar 24 '16 at 13:29
  • When you say you are using Chrome, do you mean Chrome locally or a remote instance - ie `Watir::Browser.new :chrome` or `Watir::Browser.new :remote`? I believe `session_id` is only available to the remote driver ([see the change log](https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES#L284-L295)). – Justin Ko Mar 24 '16 at 19:52
  • Yep, I was using `Watir::Browser.new :chrome`. Thanks! – pjd Mar 24 '16 at 21:24