Selenium WebDriver Recipes in Ruby 4th Edition is released
Quick solution guide to Selenium WebDriver 4.
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).
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)>’
My daughter raised this issue on Selenium’s Github. Within 1.5 days, the defect was confirmed (and fixed).
“Yup, this was trying to get index using #dom_attribute instead of #property, which was wrong. Fix is in master, look for 4.0.3 to be released soon.” — by a selenium team member
Did you get this level of support for some expensive test automation tools? I doubted it. That is one of many reasons that wise test automation engineers choose Selenium WebDriver!
About this book
“Selenium WebDriver Recipes in Ruby” 1st edition was released in 2013, on request of the readers of my other book “Practical Web Test Automation” (and later, people who attended my one-day Web Test Automation with Selenium training). They wanted a quick reference book on how to use Selenium WebDriver.
The video (animated GIF) shows find-and-run two recipes.
The second is a new Selenium v4 feature: using DevTools to download files.
Update (2021–10–21). Selenium v4.0.3 fixed the regression defect and passed all my recipe tests.