aquality-automation / aquality-selenium-dotnet

Aquality Selenium is a library built over Selenium WebDriver tool that allows to automate work with web browsers. Selenium WebDriver requires some skill and experience. So, Aquality Selenium suggests simplified and most importantly safer and more stable way to work with Selenium WebDriver.
Apache License 2.0
47 stars 14 forks source link

Error Message: System.InvalidOperationException - ChromeDriver Version Incompatibility with Chrome Version 83 #249

Closed aarif313 closed 8 months ago

aarif313 commented 8 months ago

I am trying to execute test cases on VM and getting below error,

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated) TearDown : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated)

Below are configuration of my setting file for Chrome,

"chrome": {
  "webDriverVersion": "MatchingBrowser",
  "capabilities": {
    "enableVNC": true,
    "unhandledPromptBehavior": "default"
  },
  "options": {
    "intl.accept_languages": "en",
    "safebrowsing.enabled": "true",
    "profile.default_content_settings.popups": "0",
    "disable-popup-blocking": "true",
    "download.prompt_for_download": "false",
    "download.default_directory": "./downloads"
  },
  "excludedArguments": [],
  "startArguments": [
    "--ignore-ssl-errors=yes",
    "--ignore-certificate-errors"
  ],
  "pageLoadStrategy": "Normal"
},

As I have already set webDriverVersion value to MatchingBrowser not sure why this issue is still happening.

Additionally below are Nuget packages I am using, Aquality.Selenium 4.14.1 NUnit 3.13.3 NUnit3TestAdapter 4.5.0

Requesting your kind support.

aqualityAutomation commented 8 months ago

Hello @aarif313! Since version v4.13.0 we no longer support webDriverVersion in settings(except of Opera driver). From now on, we rely on built-in Selenium Manager. It has additional ways of control, including environment variables. We have some logic built over it, you can take a look here. If you still with to use WebDriverManager, you can add the following code to be executed before your test run e.g. in your [SetUp] method before browser navigation:

new DriverManager().SetUpDriver(new ChromeConfig());

Alternatively, you can use Aquality.Selenium v4.12.3 or any previous. But, it's interesting why Selenium Manager is not working for you. Could you please share the Chrome version you are working with?

aarif313 commented 8 months ago

@aqualityAutomation

Thanks for your reply.

Regarding the version details, I've observed that both on my local machine and the VM, the Chrome version is "Version 122.0.6261.58". They appear to be identical.

The error I've shared occurs only when executing test cases on VM and does not occur when executing on my local machine.

aarif313 commented 8 months ago

@aqualityAutomation

I changed Aquality.Selenium to [v4.12.3], this giving me below error,

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.ComponentModel.Win32Exception : An error occurred trying to start process 'C:\Users**\selenium\chromedriver\win64\122.0.6261.57\chromedriver.exe' with working directory 'F:\ ** \ ** \ *****-Master-Build\web\bin\Release\net6.0-windows'. Access is denied.

mialeska commented 8 months ago

Hi @aarif313 , From my point of view, it looks like a file access issue. Please reassure that the user you are authenticated with on your VM have sufficient permissions to access both working directory (on F drive) and user directory (on C drive). And you can use the latest version of Aquality.Selenium nuget package.

If it doesn't work for you, please try adding the command

new DriverManager().SetUpDriver(new ChromeConfig(), "MatchingBrowser");

to your before tests section (if you have SpecFlow, it could be in BeforeScenario or BeforeFeature hook method).

aarif313 commented 8 months ago

Hi @mialeska @aqualityAutomation

Updated Aquality.Selenium to latest varsion 4.16.0,Additionally added below lines in [SetUp] section

new DriverManager().SetUpDriver(new ChromeConfig(), "MatchingBrowser");

But NO LUCK.

Still getting below error,

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated) TearDown : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated)

FYI, I also tried by installing and uninstalling "WebDriverManager" but nothing changed, still same error.

mialeska commented 8 months ago

@aarif313 Have you also resolved directory access issues?

In case of this error, we are logging initial exception on DEBUG level (please see the screenshot below). Could you please share this piece of your log.log file with text "session not created"? image

aarif313 commented 8 months ago

Standard_Console_Output (11).log

@mialeska @aqualityAutomation

Please find attached log file, I don't see much info in log file.

mialeska commented 8 months ago

Okay, there is not much that I can see here as well. I was talking not about console output but log.log file that should be located under \Log\log.log, this one should contain debugging info. I can guess that maybe there are multiple chrome installations with different versions on your VM (I want to see log file to confirm; if that so, you would need to specify a binaryLocation in your capabilities)...

Anyways, for now I can also suggest to try setting the environment variable "SE_DRIVER_VERSION" = "122.0.6261.57" or "SE_DRIVER_VERSION" = "122.0.6261.6901" or "SE_BROWSER_VERSION" = "122" before test execution as a temp workaround, until we find a better solution.

If this would not help as well, another shot would be to install nuget package https://www.nuget.org/packages/Selenium.WebDriver.ChromeDriver/122.0.6261.6901?_src=template

aarif313 commented 8 months ago

Dear @mialeska / @aqualityAutomation ,

Great news!

I attempted to add the environment variable "SE_DRIVER_VERSION" with the values mentioned above, but unfortunately, this did not help.

Later, I installed Selenium.WebDriver.ChromeDriver, and it successfully resolved the issue.

However, I'm curious, since the Aquality.Selenium package already includes the driver, why do we still need to install Selenium.WebDriver.ChromeDriver separately?

mialeska commented 8 months ago

yes, this would be required until your VM issue is resolved

aarif313 commented 8 months ago

Thanks for your support.