Kai Sor
unread,Apr 23, 2024, 9:47:42 AM4/23/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Selenium Users
Hello all!
I want to log network request/responses from a site. It works fine, until I switch the driver to an embedded iframe. CDP doesn't log anything that happens in the iframe, even though DevTool in Chrome shows network activities (xhr/fetch).
Switching into the iframe, and then out, also shows network logs normally after switching out, so I conclude the iframe is the issue, not the switching to iframe
Environment Info
Windows 11
C# .NET 6 (NuGet)
Chrome
Version 124.0.6367.61
Selenium.WebDriver 4.19.0.0
Selenium.Support 4.19.0.0
DotNetSeleniumExtras.WaitHelpers 3.11.0
Code
Attempt #1
var n = driver.Manage().Network;
n.NetworkRequestSent += (s, e) =>
{
Console.WriteLine(e.RequestUrl);
};
n.NetworkResponseReceived += (s, e) =>
{
Console.WriteLine(e.ResponseUrl);
};
n.StartMonitoring();
Attempt #2
var devTools = (IDevTools)driver;
var n = devTools.GetDevToolsSession().Domains.Network;
n.RequestPaused += (s, e) =>
{
Console.WriteLine(e.RequestData.Url);
return n.ContinueRequestWithoutModification(e.RequestData);
};
n.ResponsePaused += (s, e) =>
{
Console.WriteLine(e.ResponseData.Url);
return n.ContinueResponseWithoutModification(e.ResponseData);
};
n.EnableFetchForAllPatterns();
//Switch in and out of iframe
new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.XPath("/html/body/div[2]/div/iframe")));
Site Link
It's hard to find a site outside my company site (requires login), but the sign in to google button in twitter is embedded via iframe. Interacting with the pop up shows network requests in devtools, but not in CDP
Thank you again for taking the time to explore my issue, I know it's not easy to replicate and I appreciate any input!