WebDriver Firefox driver doesn't work - c#

I'm using selenium webdriver 2.42.0, Firefox 29, C# and trying to create firefox driver
FirefoxProfile fp = new FirefoxProfile();
driver = new FirefoxDriver(new FirefoxBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"), fp);
I see a new Firefox window and get WebDriverException
Failed to start up socket within 45000 ms. Attempted to connect to the following addresses: 127.0.0.1:7055
Everything works fine with ChromeDriver and IE driver. The only advise I found is to check FF and selenium versions, but as I know FF29 and webdriver 2.42 should work together.
I'm also tried to use FF27, 28, 30, nothing works.

Upgrade your selenium to newer version. If you use Maven Visit https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java

Related

Selenium C# FirefoxDriver not working for latest Selenium & Firefox

The Selenium is supposed to work with Firefox without any drivers out of the box, however I found that it is not the case with the latest Selenium & Firefox (install just days ago, Selenium 3 & Firefox ERS 52.5).
I'm following "Selenium C# and NUnit Pain Free Start Guide" as a total newbie, but found the simple Selenium C# NUnit test is not working for Firefox.
Here is my C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
namespace NewSeleniumProject
{
[TestFixture]
public class MyFirstTest
{
IWebDriver driver;
[SetUp]
public void SetupTest()
{
// driver = new ChromeDriver();
driver = new FirefoxDriver();
//driver = new FirefoxDriver(new FirefoxBinary(#"C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"), new FirefoxProfile(), TimeSpan.FromMinutes(10));
//var options = new FirefoxOptions();
//options.BrowserExecutableLocation = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
//driver = new FirefoxDriver(options);
}
[Test]
public void myFirstTest()
{
driver.Navigate().GoToUrl("http://www.swtestacademy.com");
Assert.AreEqual("SW Test Academy - Software Test Academy", driver.Title);
driver.Close();
driver.Quit();
}
}
}
And the following are my journeys to get it working.
First of all, the driver = new ChromeDriver() works for me without any hitch.
When I was using 32b Firefox ERS 52 with driver = new FirefoxDriver();, I'm getting the "Unable to determine the current version of FireFox using the registry" error, however none of the answers from Unable to determine the current version of FireFox after updated to 28.0 solves my problem. So I tried the "Try uninstalling Firefox and then re-installing it. That's what I would do" one.
Wit 64b Firefox ERS 52 (and driver = new FirefoxDriver();), I'm getting the "OpenQA.Selenium.WebDriverException : Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed." error.
When using the var options = new FirefoxOptions(), for both 32b and 64b Firefox, I'm getting "OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:6985/session timed out after 60 seconds."
Again, the whole setup I'm following is from "Selenium C# and NUnit Pain Free Start Guide". What else I'm missing? Thx.
UPDATE:
This question is not about the error:
OpenQA.Selenium.DriverServiceNotFoundException : The geckodriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
which I've fixed by downloading the driver from https://github.com/mozilla/geckodriver/releases.
Make sure versions match first. Then try this way of doing for Firefox browser. I faced same challenges before but this way of calling Firefox solved the issue. Hope it might help
var binary = new FirefoxBinary(#"----Firefox.exe Local Path------");
var profile = new FirefoxProfile();
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(#"--GeckoDriver Path-----");
service.FirefoxBinaryPath = #"----Firefox.exe Local Path------";
driverInstance = new FirefoxDriver(service);
So yes, you will need to Dl the driver and place that in your bin folder of your application and pass the path location of the .exe to the driver service using the options() with {}.
I have the same thing, however there is a difference between the two. Firefox is installed in the 64 bit folder and chrome is located in the 32 bit folder (x86) Program Files and i believe this is where there issue lies in the Selenium only looks at the 32 bit folders for the applications .exe.
I ran into the same issue when i started using any other driver apart from edge.
another issue that you may run into with the new gecko driver is that firefox will not open on the requested URL. Note that this was in VB. Should be the same though. I may just run a test.

Selenium 2.53.1 does not work on FireFox 48

I am using selenium to test our websites. When I build the project, there is an Exception :-
OpenQA.Selenium.WebDriverException: Failed to start up
socket within 45000 milliseconds. Attempted to connect to the
following addresses: 127.0.0.1:7055 and the problem is from the code
IWebDriver driver = new FirefoxDriver();
Anybody knows how to solve this problem?
Just like the other drivers available to Selenium from other browser vendors, Mozilla has released an executable that will run alongside the browser.
You can download the latest executable geckodriver from here
Add downloaded executable geckodriver to system path
The Selenium client bindings will try to locate the geckodriver (or wires) executable from the system path. You will need to add the directory containing the executable to the system path.
On Unix systems you can do the following to append it to your system’s search path, if you’re using a bash-compatible shell:
export PATH=$PATH:/path/to/directory/of/executable/downloaded/in/previous/step
On Windows you need to update the Path system variable to add the full directory path to the executable geckodriver. The principle is the same as on Unix.
After all above stuff you need to Initialize FireFoxDriver as below :-
var driver = new FirefoxDriver(new FirefoxOptions());
Note :- Follow this link for the solution of this problem with other programming language.
This answer didn't worked with me. Running selenium 2.53.6 and firefox 47 n 48.
I would recommend downloading firefox 46 which seems to be the best match for selenium 2.53.x.
https://ftp.mozilla.org/pub/firefox/releases/46.0.1/win64/en-US/
Once I downgraded to firefox 46.0.1 everything was working as expected.

error opening firefox with selenium webdriver

I have this error when open firefox
"Failed to start up socket within 45000 ms. Attempted to connect to the following addresses: 127.0.0.1:7055"
is not correct this line?
IWebDriver driver = new FirefoxDriver();
it's because I only use Visual Studio without Nunit? Firefox can be open usiong C# no? because I'm using C# not java.

Browser extension testing with selenium c# in Saucelabs

Is it possible to test browser extensions with selenium c# in Saucelab. If so how and where to place the latest extension package in saucelab VM so that selenium launches the browser with the extension.
For Firefox and chrome it is possible by providing capabilities or profile. For Example in case of firefox:
File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid startup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);

Blank firefox page launched from selenium

I am a new selenium user trying to launch Firefox from C# with selenium version 2.33.0
and Firefox version 20
Here is my code to launch firefox
var capability = DesiredCapabilities.Firefox();
Driver = new RemoteWebDriver(new Uri(Environment.SeleniumGridHubUrl), capability);
Here is my code to goto Url
Driver.Navigate().GoToUrl(Environment.Hostname[domain] + pathAndQuery);
The Firefox browser is launched successfully, however it is blank and does not display the webpage.
What I am missing here?
In your case if the gotourl is blank then you would get blank page.
This is what I usually do:
IWebDriver driver;
driver = new FirefoxDriver();
String baseURL = "http://localhost";
driver.Navigate().GoToUrl(baseURL + "/somepage.aspx");
This can happen with non compatible versions of Firefox. Make sure you turn off auto-update in the Firefox settings to avoid the latest version being installed by default.
To test that it is Firefox at fault change your WebDriver to another driver such as InternetExplorerDriver, ChromeDriver or SafariDriver.
Until Web Driver is supported, you can always downgrade your version of Firefox. Hope this helps.

Categories