-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🚀 Feature]: Switch to remote driver using an environment variable #14451
Comments
var builder = RemoteWebDriver.builder().oneOf(new ChromeOptions());
if (System.getenv("SOME_VAR") != null) {
builder.address(System.getenv("SOME_VAR"));
}
var driver = builder.build(); |
The |
@shs96c Yes, that approach using the Is it worth it? Well, I'm not sure. As I tried to explain, I believe it will be helpful for the Selenium ecosystem since it will allow the reuse of existing tests (without refactoring) to use the extra capabilities provided by a remote infrastructure (such as Grid or cloud vendors). But I'm aware this kind of change involves work from different people who maintain the bindings, and it can be difficult to do it. That's an idea I had in mind for some time and wanted to share. |
Then configure instantiation of driver instance via Seems this is good feature, but the implementation is a candidate to be landed in |
My idea is to configure only the remote URL, not all the capabilities/options. I mean, for example, this piece of code:
If the env
Notice that we are reusing the options defined programmatically by the user and using the remote URL defined as an env. With this approach, when the user does not use options in the driver instantiation (e.g., But in any case, configuring the capabilities/options in some external manner (e.g., a |
Feature and motivation
It would be super helpful to have an easy way to switch to using a remote driver instance (
RemoteWebDriver
) instead of a local driver (for example,ChromeDriver
) simply by honoring an environment variable, such asSE_REMOTE_URL
or something similar.Usage example
Imagine I have a Selenium script that uses local Chrome. For example, in Java:
This is how every developer starts using Selenium, and many Selenium tests are based. Now, suppose I want to reuse this script logic but use a remote driver. In that case, I would need to refactor my code to something like:
My vision is to avoid this code refactoring by an external configuration using an environmental variable. This way, a driver instance like
WebDriver driver = new ChromeDriver();
but executed in a machine (e.g., a CI server) with an env likeSE_REMOTE_URL=http://localhost:4444/
will use a remote browser (Chrome, in this example).Pros
Cons
RemoteWebDriver
is a parent ofChromeDriver
(and we wantChromeDriver
to behave as aRemoteWebDriver
in runtime).The text was updated successfully, but these errors were encountered: