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)