Selenium WebDriver Recipes in Ruby 4th Edition is released

Quick solution guide to Selenium WebDriver 4.

Zhimin Zhan
4 min readOct 20, 2021

--

Selenium WebDriver 4 was released last week (October 13, 2021). This major release (five years since v3) introduces many new features:

  • Relative Locators
  • Support for CDP (Selenium DevTools)
  • Re-implemented Selenium Grid

I have been updating the Selenium WebDriver Recipes in Ruby book since the first Selenium v4 Beta release (Feb. 2021). A few new chapters for those new features, as well as dozens of new recipes. All recipes have been updated and verified against Selenium 4 (ver 4.0.2). The ebook is available on Leanpub for only $9.99. Existing owners (purchased on Leanpub) will get this update free, as always. The paper and Kindle edition will be available on Amazon later this week.

As WebDriver is a W3C standard, backward compatibility is good (a minor regression issue, which I will show you shortly). I am an engineer, so I will back up my claim with numbers: only 2 out of 220 recipe tests failed for Selenium v4.0.2 (on macOS).

Test runs (of 220 recipe tests) in a BuildWise CT Server

This is another proof of why running automated regression testing in a real CT server is important.

If you have a suite of Selenium 3 tests, I recommend upgrading to v4 now (my WhenWise regression suite of 548 selenium tests has been running on v4 for over a month) unless your test scripts used this particular (not-commonly-used) syntax below.

What is the minor regression error?

Unable to select a dropdown (also known as Select List or Combobox) by index.

elem = driver.find_element(:id, "car_make_select")
select_elem = Selenium::WebDriver::Support::Select.new(elem)
select_elem.select_by(:index, 2)

Error:

Selenium::WebDriver::Error::NoSuchElementError:
cannot locate element with index: 2
./spec/ch08_select_list_spec.rb:29:in `block (2 levels) in <top (required)>’

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.