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

[🐛 Bug]: Opera Browser in Selenium 4 Usage #10835

Closed
alaahong opened this issue Jul 1, 2022 · 9 comments
Closed

[🐛 Bug]: Opera Browser in Selenium 4 Usage #10835

alaahong opened this issue Jul 1, 2022 · 9 comments
Labels

Comments

@alaahong
Copy link
Member

alaahong commented Jul 1, 2022

What happened?

2 points.

  1. As commit message mentioned, Selenium Deprecated Opera Support by non-W3C support
    [java] Add deprecated warnings to OperaDriver and OperaOptions

But as below code, Opera support W3C by additional option, so do we still need remove Opera in Selenium?
JWP -->

@Test
  public void operaOptionsTest() {
     operaOptions = new OperaOptions();
//    operaOptions.setExperimentalOption("w3c",true);
    driver = new OperaDriver(operaOptions);
    driver.get("https://www.bing.com/"); 
  }
//in log --> 7月 02, 2022 12:01:49 上午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Detected upstream dialect: OSS

W3C

@Test
public void operaOptionsTest() {
  operaOptions = new OperaOptions();
  operaOptions.setExperimentalOption("w3c",true);
  driver = new OperaDriver(operaOptions);
  driver.get("https://www.bing.com/");
} // in log --> 7月 02, 2022 12:05:22 上午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Detected upstream dialect: W3C

reference:
operasoftware/operachromiumdriver#96 (comment)
operasoftware/operachromiumdriver#100 (comment)

  1. ChromeDriver doesn't not work well with Opera
    As doc mentioned, it expect to work under ChromeOptions
    https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera

But throw exception on my side

@Test
public void operaWithChromeOptionsTest() {
  // ChromeDriver is 102.0.5005.61
  // Opera is 88 based on Chrome/102.0.5005.115
  chromeOptions = new ChromeOptions();
  chromeOptions.setBinary("/${OPERA_HOME}/opera.exe");
  driver = new ChromeDriver(chromeOptions);
  driver.get("https://www.ianzhang.cn/");
}
// org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: exited normally.
//  (unknown error: DevToolsActivePort file doesn't exist)

image

But chromeOptions with deprecated OperaDriver is fine, (it still need work with opera driver)

@Test
public void operaWithChromeOptionsAndOperaDriverTest() {
  chromeOptions = new ChromeOptions();
  chromeOptions.setBinary("/${OPERA_HOME}/opera.exe");
  driver = new OperaDriver(chromeOptions);
  driver.get("https://www.ianzhang.cn/");
}

So, any solution if user want to work with Opera by Selenium 4?

How can we reproduce the issue?

See above

Relevant log output

See above

Operating System

Windows 11

Selenium version

4.3.0

What are the browser(s) and version(s) where you see this issue?

Opera 88 (based on Chrome 102)

What are the browser driver(s) and version(s) where you see this issue?

OperaDriver 102, ChromeDriver 102

Are you using Selenium Grid?

No

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

@alaahong, 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!

@alaahong
Copy link
Member Author

alaahong commented Jul 1, 2022

@rkrupski as you point the w3c usage on OperaDriver on another post, so do you have any comment on why OperaDriver doesn't set W3C as true by default?

@titusfortner
Copy link
Member

and to what extent is it departing from chromedriver in other ways?

We could figure out a fix for DevToolsActivePort, but on Mac I'm now getting:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: unrecognized Chrome version: 1.0.0

Which means something in Opera or chromedriver changed in the past 6 months. 😞

Ruby bindings haven't directly supported Opera for the past 6+ years, and Sauce Labs has never supported it, without (much) complaint. I'm not sure how much energy to put into this one unless we can work together on a fix. Especially as we start pushing more toward async / BiDi solutions in Selenium.

alaahong added a commit to alaahong/seleniumhq.github.io that referenced this issue Jul 2, 2022
harsha509 pushed a commit to SeleniumHQ/seleniumhq.github.io that referenced this issue Jul 4, 2022
selenium-ci added a commit to SeleniumHQ/seleniumhq.github.io that referenced this issue Jul 4, 2022
@mialeska
Copy link

mialeska commented Aug 18, 2022

Found a solution unexpectedly by comparing java and dotnet implementation and documentation on selenium.dev.
Solution was to prepare proper ChromeOptions:

  1. set binary to location of launcher.exe

  2. set start arguments: "--remote-debugging-port=9222", "--no-sandbox", "--disable-dev-shm-usage"

  3. ! force set "w3c" to true.
    In java this is quite simple: options.setExperimentalOption("w3c", true);
    In C# such capability is forbidden as already known, so I had to use the reflection to forcibly add it to additionalChromeOptions private dictionary in ChromiumOptions class:

             var field = typeof(ChromiumOptions).GetField("additionalChromeOptions", BindingFlags.NonPublic | BindingFlags.Instance);
             if (field.GetValue(options) is Dictionary<string, object> optionsDictionary)
             {
                 optionsDictionary["w3c"] = true;
                 field.SetValue(options, optionsDictionary);
             }
             options.BinaryLocation = BinaryLocation;
    
  4. You need to use operadriver executable, not the chromedriver. You can check out the latest operadriver here: https://github.com/operasoftware/operachromiumdriver/releases . And you need to tell the ChromeDriver that you're using it when instantiating.

    var driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(driverDir, "operadriver.exe"), options);  
    

Hope this would help to somebody else =)

I'm working now on integration of these actions into the Aquality.Selenium nuget package, you can check out our solution - we have cross-browser support with easy json configuration. Template project is located here: https://github.com/aquality-automation/aquality-selenium-dotnet-template

@titusfortner
Copy link
Member

Opera is "officially" no longer supported in Selenium because there is not a compatible driver for it. The chromedriver now requires things that Opera does not support and operadriver does not appear to be updated with latest w3c support. If and when this changes, we can revisit support for it in Selenium.

@mialeska
Copy link

There is clearly a bug in C# Selenium version with unability to set the "w3c" option, but Selenium devs decided to close the issue... That's sad, but no suprises.
Check out our Aquality.Selenium framework — we're supporting work with different browsers including Opera, even if Selenium refuses to support them.

@titusfortner
Copy link
Member

@mialeska, It's a feature not a bug. The problem is that Opera does not support the functionality that Selenium currently requires. We've reached out to Opera devs multiple times and have not gotten any response.

If you need Opera, you can use an older version of Selenium, because Opera can't make use of the recent features, anyway.

@diemol
Copy link
Member

diemol commented Aug 22, 2022

@mialeska we are also interested in collaborating, have a look at https://twitter.com/SeleniumHQ/status/1540332236746145798

@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 Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants