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

Update BrowserWebDriverContainer to add Selenium 4 support, drop Selenium 2 support #4914

Merged
merged 7 commits into from Jan 13, 2022

Conversation

GannaChernyshova
Copy link
Contributor

@GannaChernyshova GannaChernyshova commented Jan 12, 2022

Based on #4670, #4609 and #4686

@@ -299,6 +278,16 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
* @return a new Remote Web Driver instance
*/
public RemoteWebDriver getWebDriver() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public RemoteWebDriver getWebDriver() {
public synchronized RemoteWebDriver getWebDriver() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, updated

Comment on lines 287 to 289
driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS,
() -> Timeouts.getWithTimeout(10, TimeUnit.SECONDS,
() -> new RemoteWebDriver(getSeleniumAddress(), capabilities)));
Copy link
Member

Choose a reason for hiding this comment

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

nit: while we are on it, for the sake of readability, could you please use long lambdas here? :)

Something like:

driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, () -> {
    return Timeouts.getWithTimeout(10, TimeUnit.SECONDS, () -> {
        return new RemoteWebDriver(getSeleniumAddress(), capabilities);
    });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@rnorth
Copy link
Member

rnorth commented Jan 12, 2022

Maybe mark as draft, as I know you're still working on it @GannaChernyshova, @kiview?

@kiview kiview marked this pull request as draft January 12, 2022 12:23
@kiview
Copy link
Member

kiview commented Jan 12, 2022

On merge, we need to add @tobiasstadler as co-author, since it was mostly based on his PRs.

@kiview
Copy link
Member

kiview commented Jan 12, 2022

We removed the options.addArguments("--disable-gpu") hack for now, since this should be resolved in upstream, but if we discover any kind of flakiness or high CPU usage again, we should keep this in mind.

@kiview kiview marked this pull request as ready for review January 12, 2022 12:28
Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

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

We paired on this, so approved.

Copy link
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

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

I think that this is now incompatible with Selenium 2, right? I think as a result we need a docs update (like here)

As I understand it, we have manually tested with both Selenium 3 and 4 present on the classpath, but I guess not 2 (and IMHO we should be dropping support for 2 now).

Comment on lines 233 to 241
String browserName = capabilities == null ? BrowserType.CHROME : capabilities.getBrowserName();

boolean seleniumGreaterOrEqualTo4 = new ComparableVersion(seleniumVersion).isGreaterThanOrEqualTo("4");
switch (browserName) {
case BrowserType.CHROME:
return CHROME_IMAGE.withTag(seleniumVersion);
return (seleniumGreaterOrEqualTo4 ? CHROME_IMAGE : CHROME_DEBUG_IMAGE).withTag(seleniumVersion);
case BrowserType.FIREFOX:
return FIREFOX_IMAGE.withTag(seleniumVersion);
return (seleniumGreaterOrEqualTo4 ? FIREFOX_IMAGE : FIREFOX_DEBUG_IMAGE).withTag(seleniumVersion);
default:
Copy link
Member

@rnorth rnorth Jan 12, 2022

Choose a reason for hiding this comment

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

I think the logic that we've ended up with is practically the same, but perhaps the if statements and variable names were clearer in #4609? https://github.com/testcontainers/testcontainers-java/pull/4609/files#diff-317a1df21c0090ecdecb77b75ff9e55deb8b4c56f4e6a8f084ea096e4e2e25f2R248

It's not a big deal though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed Selenium 2 support from documentation and renamed variables as in #4609. It will be good to update documentation even more (add more examples and describe some use cases) but assume it's better to do in the separate PR :)

@rnorth rnorth changed the title Selenium 4 fix Update BrowserWebDriverContainer to add Selenium 4 support, drop Selenium 2 support Jan 13, 2022
@kiview kiview merged commit f305f8e into master Jan 13, 2022
@delete-merged-branch delete-merged-branch bot deleted the selenium-4-fix branch January 13, 2022 10:11
@tobiasstadler
Copy link
Contributor

Thank You!

@kiview
Copy link
Member

kiview commented Jan 17, 2022

Thanks to you @tobiasstadler and sorry for taking some time to sort this one out.

@kiview kiview added this to the next milestone Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants