check the version of downloaded webdriver programatically - c#

I'm working on Selenium in C#. I had been using the webdriver manager to update the chrome and the firefox drivers.
new DriverManager().SetUpDriver("https://chromedriver.storage.googleapis.com/2.25/chromedriver_win32.zip",
Path.Combine(Directory.GetCurrentDirectory(), "chromedriver.exe"),
"chromedriver.exe"
);
but this is downloading the driver each time I run the program, I only want to download the driver even if it is not the latest version according to the browser's version.
How will I check the downloaded version or existing version of the web-driver
Thanks in advance

Related

When refreshing the page Selenium.WebdriverTimeoutException : Timeout receiving message from renderer: 3000 with new Chrome 103 versions in Specflow

I am running my automation in VM and Chrome version gets automatically updated. Now my VM chrome version is 103.0.5060.114(64-bit).
However, my Selenium chrome driver version is 103.0.5060.5300 which is the latest one in Nuget. Problem is I can't downgrade chrome browser. I use driver.navigate().refresh() method which was working fine a month ago.
Recently I tried different ways of refreshing and added disabling gpu still having the issue. Not sure if Chrome and/or Selenium is aware of that.
Any suggestions?
Chrome Version 103.0.5060.114 is the most updated version and well supported by ChromeDriver 103.0.5060.53 (2022-06-22). So all seems well from configuration per se.
As per the ChromeDriver 103.0.5060.53 (2022-06-22) release notes:
Supports Chrome version 103
I downgraded Chrome from 103.0.5060.114-1 to 103.0.5060.53-1 on Ubuntu like so:
1st — uninstall the current Chrome via: sudo apt remove google-chrome-stable
2nd — install the deb binary file of the chrome that you want to have:
E.g.
wget "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_{VERSION}_amd64.deb"
sudo apt install ./google-chrome-stable_{VERSION}_amd64.deb
Particularly, what I entered into the command line to downgrade:
sudo apt remove google-chrome-stable
wget "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_103.0.5060.53-1_amd64.deb"
sudo apt install ./google-chrome-stable_103.0.5060.53-1_amd64.deb
Some resources I used when I was looking for the answer for myself:
How to update Chromedriver on Ubuntu?
https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable
https://www.linuxjournal.com/content/how-can-you-install-google-browser-debian
If you are using some other system, I assume the approach would be the same.
I hope all of this would help you!

Updated Chrome Browser not found in Selenium.WebDriver.ChromeDriver NuGet package

The chrome browser upgraded to the version 89.0.4389.90.
But the Selenium.WebDriver.ChromeDriver nuget package is not available for the updated chrome version. How to upgrade selenium chrome web driver?
Chrome Selenium driver version "89.0.4389.23" is working for me with the Chrome version 89.0.4389.90 (windows 10 64 bit).
Download link: https://chromedriver.storage.googleapis.com/index.html?path=89.0.4389.23/
Can you see if it works for you as well.
I did faced an issue with chrome not starting with below error message:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: was killed.
(unknown error: DevToolsActivePort file doesn't exist)
As a workaround I did:
chromeOptions = webdriver.ChromeOptions()
chromeOptions.binary_location = "C:\...\chrome.exe"
b = webdriver.Chrome(options=chromeOptions, executable_path="<driver location>\chrome.exe")
After this I did not faced any crash issues.
Hope you find this helpful.
Note: The above code is in python but the approach should work for you.

C# visual studio selenium for edge OS version18362

I am beginner of learning C# selenium using visual studio 2015.
I want to test a random website using edge browser. With the use of NuGet, I have installed selenium support (latest version)v3.141.0, selenium webdriver (latest version)v3.141.0 and selenium microsoft webdriver (latest version)v17.17134.0. However, the OS version on my laptop (latest window 10) is 18362 which is not available to download on official webdriver website.
The following code works well in chrome, IE, and firefox, but if I run the script below, I could successfully open the edge browser, but it does not proceed any more steps accordingly (just a edge browser displaying blank page).
The error I get is as followed: OpenQA.Selenium.WebDriverException: "A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:54095/session. The status of the exception was ReceiveFailure, and the message was: the underlying connection was closed. An unexpected ...."
I searched through the entire internet but still could not find out any relevant resources teaching how to configure edge webdriver in my current situation. Can someone point out mistakes I made and advise what should be done to solve this issue?
[TestMethod]
public void TestInEdge()
{
// Default option, MicrosoftWebDriver.exe must be in PATH
IWebDriver driver = new EdgeDriver();
driver.Navigate().GoToUrl("http://testwisely.com/demo");
System.Threading.Thread.Sleep(1000);
driver.Quit();
}
Microsoft WebDriver for Microsoft Edge (EdgeHTML) versions 18 and 19 is a Windows Feature on Demand which ensures that it’s always up to date automatically and enables some new ways to get Microsoft WebDriver.
To get started you will have to enable Developer Mode:
Go to Settings > Update and Security > For Developer and then select
“Developer mode”.
To install run the following in an elevated command prompt:
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
Reference:
Microsoft WebDriver
Then after again try to run your code with Edge browser.

Microsoft webdriver and selenium webdriver causing visual studio build errors

I am trying to use Selenium Webdriver in visual studio to check a website. Everything worked fine when I was using just Chromedriver, but now that I have added the Microsoft Webdriver to test the site using Edge I am having issues. I made sure to download the correct version of the webdriver for my os build.
Every other time I go to run my test visual studio encounters a build error.
Warning Could not copy "C:\Desktop\UnitTestProject3\packages\Selenium.WebDriver.MicrosoftDriver.17.17134.0\build..\driver\MicrosoftWebDriver.exe" to "C:\Desktop\UnitTestProject3\UnitTestProject3\bin\Debug\MicrosoftWebDriver.exe". Beginning retry 9 in 1000ms. The process cannot access the file 'C:\Desktop\UnitTestProject3\UnitTestProject3\bin\Debug\MicrosoftWebDriver.exe' because it is being used by another process. The file is locked by: "Microsoft Web Driver (12804), Microsoft Web Driver (12340), Microsoft Web Driver (1124), Microsoft Web Driver (19756), Microsoft Web Driver (2592), Microsoft Web Driver (12736), Microsoft Web Driver (19604), Microsoft Web Driver (12428), Microsoft Web Driver (18604), Microsoft Web Driver (10500), Microsoft Web Driver (12724)"
If i dismiss the error and then run the test one more time it runs fine. Has anyone ran into this before?
Any help would be appreciated!
Thanks
Check your processes, May be MicrosoftWebDriver.exe is still running in process and that's why you would get build error.
If script fails abruptly, you need to handle your code to quit driver. Otherwise driver will remain active in processes.

How to deal with different browsers (Safari, Chrome, Internet explorer and opera) in selenium webdriver. What kind of libraries needs to be installed?

I am new to selenium webdriver. I have already created tests using Firefox driver but I am not able to work with the other browsers.
IWebDriver driver = new FirefoxDriver();
this.driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
this.driver.Navigate().GoToUrl("http://example.com");
this.driver.Manage().Window.Maximize();
How to create the instance for other browseers. Resources I am using (.net, Nuget Package manager, c#, selenium webdriver)?
Please advice. Thanks.
I suggest you the below Selenium WebDriver Documentation link.
Selenium WebDriver Documentation
Here you can find required details in a section called "Driver specific and Tradeoffs".

Categories