Skip to content
Go back

Test Automation Best Practices: Pinning Browser Version in Selenium Python for Stability

Published:

Introduction

Ensuring browser compatibility is crucial to maintaining test stability when running Selenium tests in a CI/CD pipeline. Recently, while executing tests in my Selenium Python example project, I encountered a breaking issue related to ChromeDriver v133 and Xvfb. This issue prevented Selenium from executing JavaScript code properly, causing tests to fail unexpectedly.

In this article, I’ll walk you through the issue, its root cause, and the solution I implemented to restore test execution.

The Problem

During a test run, I observed the following log output in the GitHub actions workflow run:

The key takeaway from this error log was:

The Solution

The solution code can be found here.

After debugging the issue, I found that Chrome v133 had a compatibility problem when used with Xvfb in Selenium tests. The simplest solution was to pin the browser version to v132 using Selenium’s built-in browser version setting.

Here’s the fix that worked for me:

Why This Works

By explicitly setting , we instruct Selenium Manager to:

  1. Download and use ChromeDriver v132, which is known to work reliably.
  2. Ensure that the installed Chrome version matches ChromeDriver v132, preventing compatibility issues.
  3. Avoid the buggy behavior observed in Chrome v133, restoring stable test execution.

Key Takeaways

Conclusion

Implementing this solution resolved the issues in my Selenium tests. If you’re experiencing similar challenges in your automation pipeline, consider pinning your browser version to maintain stability.

Happy testing!


Suggest Changes

Have a challenge? Let's Talk


Previous Post
Test Automation - How to Sync Playwright Versions Between Python and GitHub Actions
Next Post
Test Automation - Capturing Console Logs and JavaScript Errors with Selenium WebDriver BiDi in Python