Protractor directConnect driver version pinning for environment reproducibility
0 reputation · 17 Jan 2024, 18:00 UTC
0 reputation · 17 Jan 2024, 18:00 UTC
When using the directConnect: true configuration in Protractor, the framework bypasses the Selenium Server and interacts directly with the browser driver. By default, Protractor relies on the system PATH or the state of webdriver-manager to resolve the driver binary.
In a repeatable development environment, relying on the latest available driver can lead to version drift across different machines. While the configuration file allows for chromeDriver or geckoDriver path overrides to point to a specific binary, Protractor does not natively enforce a version match between the pinned driver and the installed browser version.
This creates a scenario where a configuration may be deterministic regarding the driver binary, but remains vulnerable to silent browser updates that break compatibility.
34775 reputation · 18 Jan 2024, 00:15 UTC
Protractor does not provide a native configuration property to strictly enforce a specific driver version number at runtime. When directConnect: true is enabled, Protractor resolves the driver binary via the system PATH or the specific path provided in the chromeDriver or geckoDriver configuration properties. It does not verify the version of the binary it finds against a required version string.
To ensure environment reproducibility without relying on external shell scripts, you must explicitly define the path to a known-version binary in your protractor.conf.js. This bypasses the default search logic and ensures the same binary is used across all environments that share the same directory structure.
exports.config = {
directConnect: true,
capabilities: {
browserName: 'chrome'
},
// Explicitly pin the binary path
chromeDriver: '/usr/local/bin/chromedriver-114.0.5735.90',
onPrepare: async function() {
// Custom validation logic goes here
}
};
There is no documented internal mechanism in Protractor to automatically validate that the resolved driver matches the active browser version during initialization. If a browser auto-updates, Protractor will typically throw a SessionNotCreatedError only after attempting to launch the session.
To implement a pre-flight check, you can use the onPrepare lifecycle method to query the driver's capabilities or execute a version check. Since the driver is already initialized by the time onPrepare runs, you can verify the session capabilities:
browser.capabilities() to inspect the browserVersion returned by the driver.This approach assumes that the driver binary is pre-provisioned at the specified path (e.g., via a Docker image or a CI pipeline step). Because Protractor is largely deprecated, it lacks the dynamic driver management found in newer tools like WebDriver Manager for Java or the built-in managers in Playwright/Cypress.
Diagnostic Detail Required: Are you utilizing a containerized environment (Docker) or a shared VM for these executions? If you are using Docker, pinning the driver is best handled via the image layer rather than the Protractor configuration.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.