Read more

How to provoke Selenium focus issues in parallel test processes

Henning Koch
December 06, 2012Software engineer at makandra GmbH

As attachments to this card you will find a Cucumber feature and supplementing step definition that you can use to provoke Selenium focus issues that only occur when two focus-sensitive Selenium scenarios run at the same time (probably with parallel_tests Show archive.org snapshot ). This can help you to detect and fix flickering integration tests.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

The attached feature works by going to your root_path and focusing a random form element every 5ms.

Instruction:

  • Copy the attached feature and step definition into your project.
  • If required, adjust the duration for which concurrency issues are provoked by editing focus_issues.feature (you'll see). Default is 5 minutes. It should be longer than your flickering tests take to run.
  • Make sure that your root_path contains a form element (select, input) or edit the step definition to visit another path.
  • Comment out non-flickering scenarios in your feature that contains flickering tests. The problematic feature should ideally only contain flickering Selenium-scenarios.
  • Run the feature together with the feature that contains flickering tests, e.g. with Geordi Show archive.org snapshot : cuc features/focus_issues.feature features/flickering_tests.feature
  • Be careful not to use a line number in the call. Tests will not run in parallel when a line number is used.
  • Observe how each test process now spawns a separate Firefox window (if you are using Geordi support for headless Selenium with VNC you need to call cuc-show to see the Firefoxes). Make sure that the window opened by focus_issues.feature stays on top (this will be the window showing your root_path with randomly focused input elements).
  • Wait until your flickering tests fail. You might need to run tests for a few times until this happens, because there are still external factors involved in the timing.
  • Cucumber will seem to hang until focus_issues.feature has finished its duration. You can CTRL+C out of that.

You can now fix your focus-sensitive tests.

Posted by Henning Koch to makandra dev (2012-12-06 11:45)