-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: DevTools Javascript Pin Does not work on new Tab or Window in same browser session. #11573
Comments
@Shivshive, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
The DevTools session is created by default for a 'page' target. So all the commands issued, including the ones related to script pinning will only work for that particular tab. To create a DevTools session for a particular window handle (tab or window), please use the overloaded method
|
That is what the issue is that selenium/java/src/org/openqa/selenium/devtools/DevTools.java method does not work. Even after creating a session with it and pining the javascript again, the pinned javascript doesnot work in new tab or window. As you can see from the code given in the description for same. |
Apologies. I will reopen the issue. Though the code example shared in the description is not complete, I was able to use a simpler example and recreate the issue. Thank you for bringing this to notice! I will triage it further now. |
This happens because we keep a track of pinned script per DevTools instance. So when we pin the same script again, it does not execute the commands to pin it, it returns the already pinned script's id. I think this needs to be extended to handle multiple CDP sessions within the same DevTools instance. I will try to fix this. |
The fix for this is landed. It will be available in the next release. |
What happened?
I pined a sample javascript to a browser session on win1 as -> devTools.getDomains().javascript().pin("alert_script", alertScript);
where as the alert_script is =>
String alertScript = """
When I am calling this showAlert function using Javascript executor as given below it works fine on 1st tab, but when trying to use the same function on the next tab as given in the script below it show showAlert function does not present.
I tried creating the devTools session again using devTools.createSession(driver.getWindowHandle()); but still it does not work.
Sample Code >>
How can we reproduce the issue?
Run the Code given above in description. Would be able to reproduce it.
Relevant log output
Operating System
Window 11
Selenium version
4.7.0
What are the browser(s) and version(s) where you see this issue?
109
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 109
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: