Skip to content
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

Java client bindings #23

Merged
merged 9 commits into from
Jan 19, 2021
Merged

Java client bindings #23

merged 9 commits into from
Jan 19, 2021

Conversation

bwalderman
Copy link
Contributor

Adding client language bindings for Java. Sources are found in the java/ directory. The project contains EdgeDriver, EdgeDriverService, and EdgeOptions based on the existing Selenium 3 Chrome* classes.

Selenium 4's Java bindings use separate classes for Edge Legacy and Edge Chromium instead of a single class with a UseChromium switch. Since Selenium 3 already has a driver for Edge Legacy (EdgeHTML), this project simply adds an Edge Chromium driver. The driver that ships with this project is named EdgeDriver for forwards-compatibility with Selenium 4 and because this should hopefully become the default in the future.

TODO: Deploy this to the central Maven repository and/or make available as a downloadable .jar file.


public EdgeOptions() {
setCapability(CapabilityType.BROWSER_NAME, BrowserType.EDGE);
setCapability(USE_CHROMIUM, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an API to set USE_CHROMIUM to false? Do we need a test case for USE_CHROMIUM setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Java bindings are Chromium-only unlike the other language bindings. Java users who want to test legacy Edge should continue to use the official Selenium bindings.

This is because of the way the Java EdgeDriver works in Selenium 4 Alpha. They don't have a single class with a useChromium boolean. They have separate EdgeHtmlDriver and EdgeDriver classes.

So USE_CHROMIUM is always hard-coded to true here.

}

public EdgeOptions setHeadless(boolean headless) {
args.remove("--headless");
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove --disable-gpu when headless is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This matches the existing ChromeOptions behavior in Selenium 3. The goal is to provide matching behavior.

I checked if this bug is still present in the latest official Selenium so we can fix it there. It looks like the --disable-gpu option was removed in Selenium 4.0 Alpha 1 so this is no longer a problem: https://github.com/SeleniumHQ/selenium/blob/941dc9c6b2e2aa4f701c1b72be8de03d4b7e996a/py/CHANGES#L87


import static org.junit.jupiter.api.Assertions.*;

class EdgeDriverTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some test cases to verify that the right version of edge browser (either legacy edge or chromium edge) is started with the corresponding ms:edgeChromium setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See earlier comment. This EdgeDriver is Chromium-only. I only added minimal tests to verify that Edge Chromium is launched and that ms:edgeOptions is set to true.

@microsoft-github-updates microsoft-github-updates bot changed the base branch from master to main December 10, 2020 03:05
@bwalderman bwalderman merged commit e1e1a75 into main Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants