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
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4fcc24e
Option to fix #4593 in the context of #4609
GannaChernyshova 5ceaac7
Deleted RemoteWebDriver creation from containerIsStarted
GannaChernyshova 0d74044
Added RemoteWebDriver creation to getWebDriver() method
GannaChernyshova 5c8df20
Updated default DockerImage strategy
GannaChernyshova cb1432e
Updated lambdas and added synchronized to getWebDriver
GannaChernyshova 68d530a
Removed statement of Selenium 2 support in docs
GannaChernyshova 94fce73
Renamed variables in getStandardImageForCapabilities
GannaChernyshova File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,23 +156,6 @@ protected void configure() { | |
|
||
String seleniumVersion = SeleniumUtils.determineClasspathSeleniumVersion(); | ||
|
||
if (capabilities == null) { | ||
if (seleniumVersion.startsWith("2.")) { | ||
logger().info("No capabilities provided, falling back to DesiredCapabilities.chrome()"); | ||
capabilities = DesiredCapabilities.chrome(); | ||
} else { | ||
logger().info("No capabilities provided, falling back to ChromeOptions"); | ||
capabilities = new ChromeOptions(); | ||
} | ||
} | ||
|
||
// Hack for new selenium-chrome image that contains Chrome 92. | ||
// If not disabled, container startup will fail in most cases and consume excessive amounts of CPU. | ||
if (capabilities instanceof ChromeOptions) { | ||
ChromeOptions options = (ChromeOptions) this.capabilities; | ||
options.addArguments("--disable-gpu"); | ||
} | ||
|
||
if (recordingMode != VncRecordingMode.SKIP) { | ||
|
||
if (vncRecordingDirectory == null) { | ||
|
@@ -280,10 +263,6 @@ public int getPort() { | |
|
||
@Override | ||
protected void containerIsStarted(InspectContainerResponse containerInfo) { | ||
driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, | ||
() -> Timeouts.getWithTimeout(10, TimeUnit.SECONDS, | ||
() -> new RemoteWebDriver(getSeleniumAddress(), capabilities))); | ||
|
||
if (vncRecordingContainer != null) { | ||
LOGGER.debug("Starting VNC recording"); | ||
vncRecordingContainer.start(); | ||
|
@@ -299,6 +278,16 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) { | |
* @return a new Remote Web Driver instance | ||
*/ | ||
public RemoteWebDriver getWebDriver() { | ||
if (driver == null) { | ||
if (capabilities == null) { | ||
logger().warn("No capabilities provided - this will cause an exception in future versions. Falling back to ChromeOptions"); | ||
capabilities = new ChromeOptions(); | ||
} | ||
|
||
driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, | ||
() -> Timeouts.getWithTimeout(10, TimeUnit.SECONDS, | ||
() -> new RemoteWebDriver(getSeleniumAddress(), capabilities))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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);
});
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done :) |
||
} | ||
return driver; | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, updated