C# visual studio selenium for edge OS version18362 - c#

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.

Related

Selenium headless browser testing using Triflejs

I am having some UI testcases, which are run using a Azure DevOps release pipeline. These testcases are working in Chrome and Firefox when I enable headless mode.
Now I want to enable a headless mode for Internet Explorer(IE11). When I searched on the web I found that this can be achieved using TrifleJs. How can implement TrifleJs in Visual Studio 2019? Can somebody provide the C# code?
Browser : IE11,
Server : Windows Server 2019 Datacenter
As far as I know, IE does not have support for a headless mode.
From the TrifleJs document, the TrifleJs is a kind of browser that can emulate some IE versions in a headless mode and execute JavaScript script, since its coded as a port of PhantomJS.
At present, it is an executable file, instead of a kind of SDK or API, so, we could not directly add it in C# application. I suggest you could check the document to use this tool, and you could also feedback this issue to trifleJS forum

Unable to Initialize WebDriver Chrome and all the tests are failing

I recently upgraded Chrome Browser Version to 78, Selenium Web Driver version to 3.141.0 and Selenium Chrome Driver Version to 78.0.3904.7000.
When i ran my tests on Remote Machine through Azure pipeline, all my tests are failing because of bellow failure. Please suggest how to handle this
OneTimeSetUp:
Automation.Test.Framework.Models.Exceptions.AtGenericException : Error
initializing WebDriver Chrome
----> System.InvalidOperationException : Driver does not support manipulating HTML5 web storage. Use the HasWebStorage property to test
for the driver capability
Since Chrome 75, the default setting of the w3c spec compliance has switched to true.
However the C# binding only passes the option if it is set to true (assuming the deafult to be false).
This means we cannot set it to false at all with the current stable C# binding.
https://github.com/SeleniumHQ/selenium/issues/7521

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 Open Localhost With Selenium - C# .NET

I'm testing a .Net exe web application on my local machine using Selenium web driver in Visual Studio. To view the web UI I need to open a firefox browser and connect to http://localhost:12345
When I run this code
driver.Navigate().GoToUrl("http://localhost:12345");
a browser opens but just sits blank. Then I eventually get this error in VS:
'OpenQA.Selenium.WebDriverException : Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055'
When I run the same test using Selenium IDE Firefox opens http://localhost:12345 correctly.
How do I get Firefox to open the localhost address I provide it in my C# code?
Thanks for taking the time to look at my question.
I have managed to find a solution which I will post here for anyone who encounters the same problem.
In order to access localhost I used Selenium Standalone Server instead of Web Driver. These are the steps:
1- In class under [Setup] enter
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:12345/");
selenium.Start();
verificationErrors = new StringBuilder();
}
2- Download Selenium Standalone Server
4- Run Selenium Standalone Server using cmd java -jar selenium-server-standalone-version-number.jar
5- Run test in Visual Studio
And now it works.

Selenium WebDriver 2.44 Firefox 33

I'm using Firefox version 33.1.1 and Selenium WebDriver 2.44. Selenium WebDriver was installed via Nuget using Install-Package Selenium.WebDriver. Previously I've had no problems running tests. I've started getting the following error on all my tests:
SetUp : OpenQA.Selenium.WebDriverException : Failed to start up socket within 45000 ms
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
Looking at other sources of this error with different versions of Firefox and Selenium WebDriver, i.e. Failed to start up socket within 45000, they all seem to centre on incompatibility between the Firefox version and the Selenium version. However the release notes for Selenium 2.44 indicate compatibility with Firefox 33:
http://selenium.googlecode.com/git/dotnet/CHANGELOG
Has anybody else had this error with these versions of Firefox and Selenium?
It was a version problem after all. It turns out if you're updating Selenium via nuget, you need to be aware of which project the package manager console is pointing at. I'd managed to update my main project to Selenium 2.44 but my test project was still on version 2.40.

Categories