-
-
Couldn't load subscription status.
- Fork 8.6k
make augmentation of HasBiDi/HasDevTools lazy-loaded #16338
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
7bf31b3 to
6607c45
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
6607c45 to
9e23bc1
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
9e23bc1 to
7e7bcf8
Compare
|
I have some concerns about this PR:
|
@joerg1985
No, it should not. The goal of augmentation is NOT to check all the connectivity issues. The goal is to CAST
But the augmentation is NOT automatically called on startup. AND if I really want to check BiDi connectivity, I would explicitly call some BiDi method on startup. One argument for this PR:
public HasDebugger getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
return () -> { ... ALL THE WORK ONLY HERE ...}
}
// or
public HasPermissions getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
return new HasPermissions() {
... ALL THE WORK ONLY HERE ...
};
}
|
|
@asolntsev i only wanted to point to this change in behaviour, i think having the same behaviour for all augmentations is a good idea. So i only have one comment left, all other areas rely on external synchronizations in case multiple threads are involved. |
If I understand your question correctly, then yes, the synchronization is needed in this case. @Test void augmenterThreadSafety() {
RemoteWebDriver driver = new RemoteWebDriver(gridUrl(), new ChromeOptions());
WebDriver webDriver = new Augmenter().augment(driver);
HasDevTools devTools = (HasDevTools) webDriver;
for (int i = 0; i < 10; i++) {
new Thread(() -> {
devTools.getDevTools().getDomains(); // would create multiple instances of `DevTools` without synchronization
}).start();
}
} |
|
@asolntsev in my mind the client code has to take care about synchronization, in your example: Other areas of the selenium code do not expect the client code will use different threads. e.g. the code below will end in chaos without synchronization in the client code: |
Yes, maybe this code wouldn't do anything reasonable, but it's safe. I mean, it doesn't cause connection leak etc. |
|
@asolntsev lets see what others think about this |
|
Easy, should be thread-safe. |
@nvborisenko Great! Then can we already merge this PR? |
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.
Looks good, thank you for the updates and your patience 😄
User description
When CDP url is not accessible, the command
new Augmenter().augment(remoteWebDriver)fails immediately - even if I don't want to use CDP or BiDi.🔗 Related Issues
This PR fixes the problem described in #9803, #10132, selenide/selenide#2797, selenide/selenide#3107 etc.
💥 What does this PR do?
This PR fixes
DevToolsProviderandBiDiProvider, so that augmentation ofHasBiDiandHasDevToolsinterfaces is now lazy-loaded.Context:
JavascriptExecutor:This code fails because of CDP connectivity issue during augmentation:
🔄 Types of changes
PR Type
Bug fix
Description
Make
HasBiDiandHasDevToolsaugmentation lazy-loadedFix connection failures when CDP/BiDi URLs are inaccessible
Enable augmentation to succeed even without CDP/BiDi access
Implement double-checked locking pattern for thread safety
Diagram Walkthrough
File Walkthrough
BiDiProvider.java
Implement lazy BiDi connection initializationjava/src/org/openqa/selenium/bidi/BiDiProvider.java
implementation
maybeGetBiDi()methodgetBiDiUrl()method staticDevToolsProvider.java
Implement lazy DevTools connection initializationjava/src/org/openqa/selenium/devtools/DevToolsProvider.java
implementation
maybeGetDevTools()method