Posted about 7 years ago. Visible to the public.

How to provoke Selenium focus issues in parallel test processes

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). This can help you to detect and fix flickering integration tests.

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


  • 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: 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.

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Henning Koch
Last edit:
about 7 years ago
focus_issues.feature, focus_issue_steps.rb
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more