[🐛 Bug]: CDP - Emulate network condition not applied for more than one browser tab
See original GitHub issueWhat happened?
Hi, I wanted use CDP methods in my tests and I faced with command like Network.emulateNetworkConditions. In my tests Im using one chrome/edge instance for two different users - Client/Admin. For example, test opens first tab for client and second tab for admin. I wanted emulate network conditions, but this works only for second(last browser tab).
My expectations was: client(first tab) should has applied Network.emulateNetworkConditions(offline), but it was applied only for second tab(Admin). I tried get all targets and get first tab target and after that use method for AttachToTarget(firstTabTargetId), but this didnt work also.
Its bug or I dont understand how it works?
Thanks
How can we reproduce the issue?
Code for reproduce this issue.
[Test]
public async Task SeleniumCdpTestForEmulateNetwork()
{
_driver.Navigate().GoToUrl("http://www.google.com");
Thread.Sleep(2000);
_driver = _driver.SwitchTo().NewWindow(WindowType.Tab);
_driver.Navigate().GoToUrl("http://stackoverflow.com");
Thread.Sleep(2000);
var session = (_driver as IDevTools).GetDevToolsSession();
var commandParams = new JObject(
new JProperty("offline", true),
new JProperty("latency", 0),
new JProperty("downloadThroughput", -1),
new JProperty("uploadThroughput", -1));
await session.Domains.Network.EnableNetwork();
await session.SendCommand("Network.emulateNetworkConditions", commandParams);
_driver.SwitchTo().Window(_driver.WindowHandles[0]);
}
Relevant log output
No logs for this behaviour.
Operating System
Windows 10
Selenium version
Selenium.WebDriver 4.4.0 / netcoreapp3.1
What are the browser(s) and version(s) where you see this issue?
Chrome 105.0.5195.102
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 105.0.5195.1900
Are you using Selenium Grid?
No
Issue Analytics
- State:
- Created a year ago
- Comments:11 (7 by maintainers)

Top Related StackOverflow Question
Oops, I mis-tagged this, sorry! Thanks for looking @TamsilAmani
You are right, @TamsilAmani, the code is .NET.
If you have time, any help triaging issues is appreciated 🙇