Skip to content

Use Driver finder for sending Options to Selenium Manager#11411

Closed
titusfortner wants to merge 3 commits intotrunkfrom
driver_finder
Closed

Use Driver finder for sending Options to Selenium Manager#11411
titusfortner wants to merge 3 commits intotrunkfrom
driver_finder

Conversation

@titusfortner
Copy link
Copy Markdown
Member

This is an alternative implementation to #11376 for using Options class to work with SeleniumManager.

Instead of storing options instance in the DriverService class and using it in the findExecutable() method, this PR moves the driver finding pieces out of service classes. There are currently 2 methods, one with options parameter that can call SeleniumManager and one without options. The goal is to get everything to go through that method, and the trick is going to be figuring out how to make that happen (I think it can be done with a combination of deprecations and warning messages).

I think this one can be merged as-is, but at the least it needs more javadocs and someone(s) to make sure I've thought everything through.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 11, 2022

Codecov Report

Base: 54.54% // Head: 54.54% // No change to project coverage 👍

Coverage data is based on head (5289585) compared to base (4071737).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #11411   +/-   ##
=======================================
  Coverage   54.54%   54.54%           
=======================================
  Files          85       85           
  Lines        5627     5627           
  Branches      243      243           
=======================================
  Hits         3069     3069           
  Misses       2315     2315           
  Partials      243      243           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@titusfortner titusfortner added the C-java Java Bindings label Dec 16, 2022
return score;
}

public Builder withOptions(SafariOptions options) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, I observed the options are passed but not used. Is that intentional?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it consistent with the others. It's just to avoid telling everyone they need to use the withOptions method if they want to start a service and then say "except here". I'm fine to remove it if we want to go this route.

}

public Builder withOptions(SafariOptions options) {
return this;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same observation here

Comment thread java/src/org/openqa/selenium/manager/SeleniumManager.java
@pujagani
Copy link
Copy Markdown
Contributor

LGTM

@sonarqubecloud
Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 10 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Copy Markdown
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we need the *DriverFinder.java classes. I think we can call DriverFinder.findExecutable from the driver class.

Nevertheless, I think we do not want to follow this approach which implies sending options to the driver service? So far #11491 looks better to me.

* Configures and returns a new {@link ChromeDriverService} using the supplied configuration. In
* this configuration, the service will use the ChromeDriver executable identified by the
* {@link #CHROME_DRIVER_EXE_PROPERTY} system property. Each service created by this method will
* {@link ChromeDriverFinder} system property. Each service created by this method will
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that is correct? There is no ChromeDriverFinder system property.

Comment on lines +1 to +25
package org.openqa.selenium.chrome;

import org.openqa.selenium.remote.service.DriverFinder;

import java.io.File;

import static org.openqa.selenium.chrome.ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY;
public class ChromeDriverFinder extends DriverFinder {
protected static File findExecutable() {
return findExecutable(
"chromedriver",
CHROME_DRIVER_EXE_PROPERTY,
"https://chromedriver.chromium.org/",
"https://chromedriver.chromium.org/downloads");
}

protected static File findExecutable(ChromeOptions options) {
return findExecutable(
"chromedriver",
CHROME_DRIVER_EXE_PROPERTY,
"https://chromedriver.chromium.org/",
"https://chromedriver.chromium.org/downloads",
options);
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not following why we need this class. Why don't we call DriverFinder.findExecutable in ChromeDriver? We could put all hard coded values in variables, make the call from there and avoid this extra class.

This comment also applies for the rest of the drivers.

@titusfortner titusfortner removed the A-needs decision TLC needs to discuss and agree label Jan 6, 2023
@titusfortner
Copy link
Copy Markdown
Member Author

We decided to go with #11491

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-java Java Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants