fix flaky Ruby test `element_spec.rb` (#16709)
* fix flaky Ruby test `element_spec.rb`
Wait until the new URL gets loaded.
Sometimes after executing `driver.navigate.to url_for('new_page.html')` the browser is still showing the previous page.
Example of failure:
```ruby
Selenium::WebDriver::Element raises if different element receives click
Failure/Error: element = wait_for_element(id: 'contents', timeout: 10)
Selenium::WebDriver::Error::TimeoutError:
could not find element {:id=>"contents", :timeout=>10} in 25 seconds;
page url: http://localhost:49887/resultPage.html?x=25&y=25;
page source:
<p id="greeting">Success!</p> ...
# ./rb/lib/selenium/webdriver/common/wait.rb:76:in `until'
# /Users/runner/work/selenium/selenium/rb/spec/integration/selenium/webdriver/spec_support/helpers.rb:93:in `wait_for_element'
# ./rb/spec/integration/selenium/webdriver/element_spec.rb:35:in `block (2 levels) in <module:WebDriver>'
```
See https://github.com/SeleniumHQ/selenium/actions/runs/20055175531/job/57520193372#step:19:920 for example.
* Open a blank page before every test
It's a good practice to avoid tests affecting each other:
1. Open "about:blank" page - this stops any current activity / background requests / animations on the previous page
2. Open an empty page which clears sessionStorage, localStorage and cookies.
This technique allows reusing the browser between tests, while keeping the tests independent. A
Andrei Solntsev committed
88a8296590228716c64947569b77f726997ff191
Parent: 7284ec4
Committed by GitHub <noreply@github.com>
on 12/10/2025, 6:03:02 PM