I'm trying to use Selenium 3.5.2 with C #, but I always get the error "Unable to find a matching set of capabilities" every time I try to instantiate the webdriver.
I'm currently using Visual studio 2015 with Selenium 3.5.2, GeckoDriver 0.18 64bit and Firefox 55.0.3 64bit.
Here the code:
var driverService = FirefoxDriverService.CreateDefaultService(DriverPath, DriverName);
driverService.FirefoxBinaryPath = FirefoxPath;
var firefoxOptions = new FirefoxOptions();
var webDriver = new FirefoxDriver(driverService, firefoxOptions, TimeSpan.FromSeconds(10));
webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(0);
webDriver.Navigate().GoToUrl(new Uri("http://www.google.com"));
Where DriverPath, DriverName and FirefoxPath are respectively path of geckodriver executable, geckodriver executable name and firefox executable path (they seems to be fine, when I run the code I can see the firefox slashscreen and geckodriver prompt console).
Does anyone know how to avoid this error?
Related
Is it possible to open my own (normal) chrome browser and have selenium run on this browser?
I saw some existing topics about this wrt. Python: Running Selenium on an existing Chrome Browser Window, how is someone doing this through C# and Selenium?
Type : chrome://version/ in browser you will get executable path of chrome.exe
copy this and close all chrome instance.
**close all chrome instance and **
start chrome as:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=5555
verify chrome is started with port open by going to localhost:5555
Now add remote debugging port as:
var options = new ChromeOptions();
options.debuggerAddress= "127.0.0.1:5555";
var driver = new ChromeDriver(options);
I am new to Selenium and after exhaustive research I can't find a reliable example to launch Firefox with my default profile so I retain my extensions, bookmarks etc. Much has changed and the examples I find are now deprecated or use Java syntax. Here's my set up:
Visual Studio 2017 Community
C# - Selenium WebDriver 3.13.1
Selenium WebDriver Support
geckodriver - Firefox v. 61.0.1
References have been set on the solution. Here is my code:
FirefoxProfileManager myProfile = new FirefoxProfileManager();
FirefoxProfile profile = myProfile.GetProfile("C:\\Users\\Robert\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\4halwx5j.default");
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
IWebDriver driver = new FirefoxDriver(options);
driver.Url = "https://lastpass.com/?ac=1&lpnorefresh=1";
driver.Manage().Window.Maximize();
Would anyone be so kind to provide an example that works using WebDriver 3.13.1 FF v. 61.0.1and C# syntax?
I am attempting to open Chrome browser with an extension. Chrome opens, but it doesn't have my extension. Here is my code. Please let me know what I am doing wrong.
private IWebDriver GetChromeDriver(BrowserConfigurationOptions browserConfigOptions)
{
var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var chromeDriverPath = Path.GetFullPath(outPutDirectory + #"\Drivers");
var options = new ChromeOptions();
options.AddExtension(outPutDirectory + #"\3.1.5_0.crx");
options.AddArguments("disable-infobars");
options.AddUserProfilePreference("credentials_enable_service", false);
if (browserConfigOptions.KioskModeForChrome)
options.AddArgument("--kiosk");
return new ChromeDriver(chromeDriverPath, options);
}
The extension exists in the path where I expect it to be.
Chrome version: 60
ChromeDriver v:2.29
Selenium v: 3.5.2
The issue is that WebDriver 3.5.2 does not support ChromeDriver 2.29. These problems can be resolved if we downgrade to WebDriver 3.4. Then everything works. I logged an issue on their Github but I believe that backwards compatibility is not expected between WebDriver and older versions of ChromeDriver.
I have an infuriating Selenium error:
The path to the driver executable must be set by the webdriver.chrome.driver system property
Here is the code I am using:
Environment.SetEnvironmentVariable("webdriver.chrome.driver", #"C:\ChromeDriver\chromedriver.exe");
DesiredCapabilities capability = DesiredCapabilities.Chrome();
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = #"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
capability.SetCapability(ChromeOptions.Capability, options);
Uri url = new Uri("http://localhost:5050/wd/hub");
//error on this line
IWebDriver driver = new RemoteWebDriver(url, capability);
I have the driver on disk, at the location.
The selenium server is running, as shown below:
Server
I have added the selenium binary as a system variable, as shown below:
Variables
I have restarted the server too.
What am I missing? It feels as though I am doing everything correctly, but it's not working.
Thanks
With the new selenium, which is 3.0 you should use:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium-server-standalone-3.0.0-beta2.jar
If you are using selenium version below 3.0 you need to reverse the order of selenium with the driver, like:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium_server.jar
Also make sure selenium server is compatible with chromedriver.
Other thing to check is that chrome browser is up to date.
I'm using the C# bindings for Selenium and trying to get a simple automated test in Microsoft Edge working.
class Program
{
static void Main(string[] args)
{
EdgeOptions options = new EdgeOptions();
options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
RemoteWebDriver driver = new EdgeDriver();
driver.Url = "http://bing.com/";
}
}
But the program halts on the initialisation of the EdgeDriver, the edge browser launches but the url never changes to "bing.com".
Has anyone else experienced this?
I have faced the same issue. I followed the below steps to resolve it :-
Download the correct Microsoft WebDriver server version for your build.
How to find your correct build number :-
1- Go to Start > Settings > System > About and locate the number next to OS Build on the screen. This is your build number. Having the correct version of WebDriver for your build ensures it runs correctly.
2- Run this command systeminfo | findstr /B /C:"OS Version" this will give the output like OS Version: 10.0.10586 N/A Build 10586. Here is build number is 10586
You need to check your Windows OS build number and download appropriate .msi and install it.
Provide the Syetem property where MicrosoftWebDriver.exe installed to webdriver.edge.driver.
Note :- The Default installed location of the MicrosoftWebDriver.exe :-
for 64 bit is C:\Program Files (x86)\Microsoft Web Driver
for 32 bit is C:\Program Files\Microsoft Web Driver
Hope it will work...:)
This happens when your system does not match the webdriver version... Determine which release of Windows 10 you are using... then go here and download same release..
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver
Here's what the error looks like when the versions don't match.
Selenium will Hang
EdgeOptions options = new EdgeOptions();
options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
RemoteWebDriver driver = new EdgeDriver();
driver.Url = "http://bing.com/";
Results in this exception with Edge still up and on the Bing page
Exception Thrown
changing the code to this, with no options:
var driver = new EdgeDriver();
driver.Url = "http://bing.com/";
Results in this:
Exception thrown: 'System.InvalidOperationException' in WebDriver.dll
And this in the console.
Something's not right with the MicrosoftWebDriver.Exe which was downloaded from here. https://www.microsoft.com/en-us/download/details.aspx?id=48212 and installed into the Program Files folder by default. Here's screenshot of add/remove programs. System is Windows 10 PRO 64 bit.
Note I did not try the 32 bit version