-
-
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]: networkConnectionEnabled capability chromeOptions does not work anymore with Selenium 4.9.0. #11923
Comments
@czp13, 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! |
Potential cause changes here made The Any workaround for this? Thank you! 🙏 |
The workaround is to use W3C only capabilities. Where are you using that capability? |
Yes, this needs to be set in It should work to do:
But also, I'm not sure you need it for anything? What is your use case? |
Thank you @titusfortner and @diemol. It is an old code piece in our testing setup. The information I have is that this was needed for offline emulation, and needed to add some device mod as well. Here: Code piece: @Before
@Override
public void setup() throws Exception {
ChromeOptions chromeOptions = customizeChromeOptions(
new ChromeOptions());
WebDriver driver;
if (Browser.CHROME == getRunLocallyBrowser()) {
driver = new ChromeDriver(chromeOptions);
} else {
URL remoteURL = new URL(getHubURL());
driver = new RemoteWebDriver(remoteURL, chromeOptions);
setDevToolsRuntimeCapabilities((RemoteWebDriver) driver, remoteURL);
}
devTools = new DevToolsWrapper(driver);
setDriver(TestBench.createDriver(driver));
}
protected ChromeOptions customizeChromeOptions(
ChromeOptions chromeOptions) {
// Unfortunately using offline emulation ("setNetworkConnection"
// session command) in Chrome requires the "networkConnectionEnabled"
// capability, which is:
// - Not W3C WebDriver API compliant, so we disable W3C protocol
// - device mode: mobileEmulation option with some device settings
final Map<String, Object> mobileEmulationParams = new HashMap<>();
mobileEmulationParams.put("deviceName", "Laptop with touch");
// chromeOptions.setExperimentalOption("w3c", false);
chromeOptions.setExperimentalOption("mobileEmulation",
mobileEmulationParams);
chromeOptions.setCapability("networkConnectionEnabled", true);("networkConnectionEnabled", true);
if (getDeploymentHostname().equals("localhost")) {
// Use headless Chrome for running locally
if (!isJavaInDebugMode()) {
chromeOptions.addArguments("--headless", "--disable-gpu");
}
} else {
// Enable service workers over http remote connection
chromeOptions.addArguments(String.format(
"--unsafely-treat-insecure-origin-as-secure=%s",
getRootURL()));
// NOTE: this flag is not supported in headless Chrome, see
// https://crbug.com/814146
// For test stability on Linux when not running headless.
// https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t
chromeOptions.addArguments("--disable-dev-shm-usage");
}
return chr
} |
Hmm, it doesn't show up as required in their docs - https://chromedriver.chromium.org/mobile-emulation |
Well, I tried with your idea and it seems like this param was needed, I got this error now:
Full error log:
|
@titusfortner: Is not it possible that this change is a regression, backward compatibility broking change? |
If your code is W3C compliant, it is a regression. Therefore we need a piece of code that we can simply copy and paste in our IDE to reproduce the issue. When that is present, I'd be happy to reopen and triage. |
It is not W3C compliant I believe, but we needed to use it. The best would be to somehow replace it with the W3C-compliant version of it, I can share again the code piece. But basically, this is it, from here:
@diemlo: Any idea how to rewrite this to be w3c compliant? 🙇 |
The error message is saying that chromedriver doesn't recognize this parameter, which should mean that it isn't necessary for your use case. Did you try just not setting it? Most likely it was being ignored in the previous version of Selenium. If you don't set it and get an error, let us know what the error is. |
@titusfortner: Thank you for your ideas. I did not try to not set it, I could try it. What I did was refactor and remove many code pieces in our testing repository/project. The code removals solved my problem :), and it worked and the test passed without problems with the newest Selenium. I hope I can get approved soon for my PR and then this will be solved. Also understood through my investigations that this whole networkConnectionEnabled was used to be able to use Aeroplane mode and other modes. (NetworkConnection.ConnectionType.AIRPLANE_MODE). |
@titusfortner: Got a different exception:
|
4.9 only supports CDP for
Oh interesting, thanks for sharing that; I'm not very familiar with the mobile package. |
Thank you @titusfortner. I tried with v110, and some tests are still failing, but I hope, and believe we are closer to fixing this problem. Indeed this is more complicated, usually updating a dependency is just bumping the version in pom.xml, but here much more is needed, and maybe this jump from 4.8 to 4.9 is bigger than usual :). Thanks for the discussion, ideas/insights, guide tho! 🙇 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What happened?
The newest version of Selinium is not supporting anymore to setup
networkConnectionEnabled
true:Causing this:
This was used for mobile testing.
How can we reproduce the issue?
With updating the following dependency:
To:
And using the remoteWebDriver like this:
Will generate the exception.
The text was updated successfully, but these errors were encountered: