C_K_Coal
C_K_Coal

Reputation: 3

How to avoid loss of driver object?

i am trying to migrate our test automation from watir-classic to watir-webdriver. (Ruby 2.0, watir-webdriver 0.9.1) Which is working fine in general, but our login process gives me a headache.

Lets me short explain what happens:

With the closing of Website A, the driver is also lost, i currently i cannot make a new instance of the driver to connect to the Website B.

when i try to do create an instance of the following pageobject, i get :

variable name="@exception" kind="instance" value="Unable to get browser" type="Selenium::WebDriver::Error::NoSuchWindowError"

I do this by:

  def click_loginbtn
    @@driver.button(id: 'loginBtn').click
    return ProjectList.new(@@driver)
  end

Has anyone a good idea for this?

Upvotes: 0

Views: 71

Answers (1)

titusfortner
titusfortner

Reputation: 4194

Your driver is still active, you just need to access the new window.

To get a list of active windows available:

@browser.windows

You can switch to another window by handle, title, url, index or collection

@browser.window(title: 'My new window').use
@browser.windows.first.use

Upvotes: 1

Related Questions