DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on

Capybara::Session Page Navigations

The code on GitHub

πŸ‘browser back & forward

go_back
go_forward
visit(https://dev.to/new)

πŸ‘window(tab) switch and close

OLD WAY

window = page.driver.browser.window_handles
if window.size > 1 
  page.driver.browser.switch_to.window(window.last)
  page.driver.browser.close
  page.driver.browser.switch_to.window(window.first)
end

NEW WAY

switch_to_window(window_opened_by{ click_link('click here!') })
# do something

switch_to_window(windows.first)

Better Way

In this way, you don't need to back by manually.

within_window(window_opened_by{ click_link('click here!') }) do
  # do something
end

πŸ‘get Http responses

status_code
response_header

πŸ”— Parent Note

Top comments (0)