From 856fe03b0171091f1cf35bcac6ddaca4e991f6c4 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 3 Nov 2017 10:37:22 -0500 Subject: [PATCH] Add Navigate Back In The Browser With Capybara as a ruby til --- README.md | 3 ++- .../navigate-back-in-the-browser-with-capybara.md | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ruby/navigate-back-in-the-browser-with-capybara.md diff --git a/README.md b/README.md index 1074780..cb45d7c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_581 TILs and counting..._ +_582 TILs and counting..._ --- @@ -444,6 +444,7 @@ _581 TILs and counting..._ - [Last Raised Exception In The Call Stack](ruby/last-raised-exception-in-the-call-stack.md) - [Limit Split](ruby/limit-split.md) - [Listing Local Variables](ruby/listing-local-variables.md) +- [Navigate Back In The Browser With Capybara](ruby/navigate-back-in-the-browser-with-capybara.md) - [Next And Previous Floats](ruby/next-and-previous-floats.md) - [Or Operator Precedence](ruby/or-operator-precedence.md) - [Override The Initial Sequence Value](ruby/override-the-initial-sequence-value.md) diff --git a/ruby/navigate-back-in-the-browser-with-capybara.md b/ruby/navigate-back-in-the-browser-with-capybara.md new file mode 100644 index 0000000..6f8712f --- /dev/null +++ b/ruby/navigate-back-in-the-browser-with-capybara.md @@ -0,0 +1,15 @@ +# Navigate Back In The Browser With Capybara + +There are two ways to navigate back to a previous page. Capybara is driving +the browser and it can be instructed to go back using its built-in command +or by executing some JavaScript. + +```ruby +page.go_back +``` + +or + +```ruby +page.evaluate_script('window.history.back()') +```