-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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]: RequestWillBeSent doesn't work when the link opens another tab #10161
Comments
@lopukhDA, 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, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
I also ran into this, and have tried multiple things that so far have not resulted into something I consider a decent solution. So far I have figured out that when working with multiple tabs in DevTools you have to use the Target domain to subscribe to TargetCreation (think Browser tabs, Service workers etc). However the SetAutoAttach command that should be used does not seem to do anything. I'm able to receive This manually attaching of a Target causes a new devtools sessions to be created. Which in itself is an issue because the DevToolsSession exposed by selenium only works on a single After some messing around I have this janky setup where I'm able to activate the network domain for the new session targeting said new tab, by using reflection to change the I would summarize the issues that I'm running into when working in multiple tabs as following:
At this point I'm consider myself to be stuck and could use some guidance on this subject as well. |
For what it's worth; I created a PR which allows you to handle the WaitForDebuggerOnStart property correctly using Selenium. You can subscribe to the AttachToTarget event on the Target domain. I use the following code to properly attach Selenium to the new DevTools target. When creating the DevToolsSession you should set the WaitForDebugger property to true.
|
This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
Reopened. We need triage it. |
@nvborisenko can you give a status update on this? Thanks. |
Is in progress. |
@nvborisenko do you have any info when this issue will be fixed? In lot of cases when a new tab automatically opened requests can't catch with devtoola |
I am afraid nobody is interested in to fix it. Seems fixing this "legacy" issue is risky. Good news is that BiDi is coming! I already "tried" it, and this use-case is considered at design level of the specification. Any ETA... I would say it is closer than never has been. |
Just this week I managed to track down the actual issue for which I raised the SendCommands PR a while back, which is the final part which is needed to get this to work. It comes down to the handling of events coming from the browser (DevToolsSession.ProcessIncomingMessages function) and sending commands (DevToolsSession.SendCommand function) are locking each other. However a lot of changes were needed to fix that, but we have it working on our internal repository now. To summarize what I had to change
This results in the entire flow of raising events from DevTools to responding to those fully async-await. My internal repository is now quite far off from the public repository, so not quite sure what to do with it. |
This isn't really an option for us right now, anyway. We're discussing different options for BiDi approach in our chat room if you would like to participate — https://www.selenium.dev/support/#ChatRoom The current WebDriverBiDi.NET implementation that I started to work with, has decided, based on this conversation, to switch to an Observer pattern. So now we're rethinking what we want to do in Selenium. I think @nvborisenko wants to create his own implementation for Selenium, but I'm really reluctant to have 2 separate implementations maintained by the community. |
@EdwinVanVliet can you elaborate more about
What is your use case? Deprecate my message. The actual one is: "Do you think we can land your changes into this code base?". |
If you PR the following, please!
If you PR the following, please!
|
I will close this because it went stale. |
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs. |
What happened?
Hello. I am using selenium to check submitted Requests from a page. I use the Network.RequestWillBeSent event for this. Everything works well until I come across a link that opens a new tab. Such links usually have a target = "_blank" attribute. When a new tab opens, I do not receive requests from it. I can only get requests from the initial tab.
How can I get all the requests from the new tab? If I need to initialize a new RequestWillBeSent event for a new tab, then I will miss the first requests from the page, which are very important to me.
I was trying to switch to another tab using driver.SwitchTo().Window(window), but that doesn't work.
How can we reproduce the issue?
Relevant log output
Operating System
Windows 10
Selenium version
Selenium 4.1, .Net Core 5 or .NET Framework 4.7.2(C# 8)
What are the browser(s) and version(s) where you see this issue?
Chrome 96
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 96
Are you using Selenium Grid?
no
The text was updated successfully, but these errors were encountered: