How to switch tab in cuprite and assert content?

299 Views Asked by At

I'm using cuprite 0.13 Capybara 3.53.3 Rspec 3.11

I have a simple spec that clicks on the link with target="_blank" attribute.

      new_window = page.window_opened_by do
        click_on "Link with target blank"
      end

# I'm trying to test it capybara way

      within_window(new_window) do
        expect(page).to have_text("Some text")
      end

But getting this error

Ferrum::JavaScriptError (ReferenceError: _cuprite is not defined)
    at HTMLHtmlElement.<anonymous> (<anonymous>:1:15)

Switch manually procudes same error page.driver.browser.switch_to_window(new_window.handle)

1

There are 1 best solutions below

0
Constantin De La Roche On

This worked for me with cuprite (0.14.3) & capybara (~> 3.0):

page.driver.browser.switch_to_window(page.driver.browser.window_handles.last)

Cf. switch_to_window