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)