Skip to content
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

[🚀 Feature]: Support disable-build-check in c# chromedriver implementation #10898

Closed
ojintoad opened this issue Jul 21, 2022 · 7 comments
Closed

Comments

@ojintoad
Copy link

Feature and motivation

Sometimes Chrome/Chromedriver versions that are compatible have bugs which makes upgrading or downgrading temporarily to a distinct chromedriver version desirable.

One example is:

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4121

This was fixed in the next beta release of chromedriver for several weeks before getting backported to the version where it was originally broke. Trying to run the beta 104 chromedriver against the stable 103 chrome browser was impossible in C# powered selenium automation because the current ChromeDriverService and ChromiumService in C#:

  • Uses sealed classes and protected constructors
  • Doesn't have support for the property disableBuildCheck arguments

For reference, this is the flag in chromedriver:

https://github.com/bayandin/chromedriver/blob/d9865ee18a2ac228d4e5f41ff2c950992cc0b788/chrome_launcher.cc#L280

Java supports the flag, as introduced by @diemol:

if (disableBuildCheck) {
args.add("--disable-build-check");
}

C# does not:

protected override string CommandLineArguments

Can this be added to the c# implementation of chromedriver?

Usage example

I tried to explain that in the Feature and Motivation, let me know if that wasn't clear enough from that section and I can attempt to explain further.

@github-actions
Copy link

@ojintoad, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner
Copy link
Member

This line in the Java code is a shortcut that is used by the grid, and isn't necessary for the functionality you want.

In C# you just need to do:

ChromeOptions options = new ChromeOptions();
options.AddArgument("--disable-build-check");

@ojintoad
Copy link
Author

If that's true, that will be a relief.

My understanding was that ChromeOptions are not passed to the ChromeDriver as arguments but rather to the ChromeBrowser process it starts up. It sounds like you're saying I'm mistaken on that.

I will work with my team to confirm your example code works today.

@ojintoad
Copy link
Author

Just to be clear, my understanding was based on this post "--disable-build-check has no effect" - admittedly it is old (2019) and for Java, and C# may behave differently.

This flag isn't a Chrome switch, it's a ChromeDriver switch. The Selenium libraries don't make these easily accessible to code. If you start ChromeDriver independently on the command line, then of course it is easy to add the switch. At the bottom of this page are instructions for connecting to such an instance: https://chromedriver.chromium.org/getting-started

@ojintoad
Copy link
Author

@titusfortner I tested locally and the code you've suggested doesn't seem to work.

Steps I took:

  1. Updated my project to use the preprelease nuget chromedriver package of https://www.nuget.org/packages/Selenium.WebDriver.ChromeDriver/104.0.5112.2900-beta
  2. Added the code before the driver gets created like...
options.AddUserProfilePreference("permissions.default.microphone", 1);
options.AddArgument("--disable-build-check");

var driver = new ChromeDriver(driverService, options);
  1. Ran a Selenium test. The exception I got back was:

System.InvalidOperationException: 'session not created: This version of ChromeDriver only supports Chrome version 104
Current browser version is 103.0.5060.134 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe (SessionNotCreated)'

Just to cover an odd case, I also tried

options.AddArgument("disable-build-check");

without the prefix dashes, and that also did not work.

I should have clarified as well in the original opening of this, I had gotten clearance to write up a feature request from @diemol in the Selenium users slack after discussing there. I'll tag you into that thread.

Is there anything else you would want me to try? If not, can we please reopen this?

@titusfortner
Copy link
Member

Oh, yeah, I see what you mean, this is an arg for the driver, not the browser. Weird that .NET and Java lock this down so much, but sure.

Fixed: 6f082ed

Available next release

@github-actions
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants