WebDriver with Java code does NOT open Firefox and does nothing in Windows XP
Solution 1
I've got the same error. Windows + FF 14.0 and
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.21.0</version>
</dependency>
I've debugged the code and i checked that the Thread is stucked on class FirefoxBinary, inside the method
public void clean(FirefoxProfile profile, File profileDir) throws IOException
the profile.isRunning(profileDir) always returns true... that's why nothing happens...
if (Platform.getCurrent().is(Platform.WINDOWS)) {
while (profile.isRunning(profileDir)) {
sleep(500);
}
do {
sleep(500);
} while (profile.isRunning(profileDir));
}
Then i updated to 2.25 and it worked!
<dependency>
<groupId>org.seleniumhq.selenium</groupId>]
<artifactId>selenium-java</artifactId>
<version>2.25.0</version>
</dependency>
Solution 2
Although it's an old post, but if someone will be looking for an answer, this helped me in similar case:
FirefoxProfile profile = new FirefoxProfile();
FirefoxBinary binary = new FirefoxBinary(@"path\to\firefox.exe");
FirefoxDriver driver = new FirefoxDriver(binary,profile);
Solution 3
To open firefox you will have to use the selenium firefox driver.
Refer to this simple example at this link - The 5 Minute Getting Started Guide
Let me know if the firefox browser opens up after you initialize the firefox driver.
Mohammed Akram
Working as Software Engineer - Testing with overall 4+ years of Overall experience, I am working/worked on Automation tools such as Selenium WebDriver and Robotium. I like exploring new testing tools and work on them.
Updated on July 09, 2022Comments
-
Mohammed Akram almost 2 years
I am trying to run Selenium2 (known as WebDriver) with Java in Firefox. It does not even open the Firefox and throw any error in the console. It stays idle and does nothing..
I am using FF 13 beta Selenium WebDriver 2.23.1(Latest) Win XP
I also tried Downgrading FF version(Changed to 9), It didn't work, Updated WebDriver to Latest(2.23.1) from 2.22, It didn't work
When I run this code in InternetExplorer(8), It will open the browser but will not identify any element and test fails..
My code:
public class Selenium2Example { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); } }
-
Mohammed Akram almost 12 years:I have initialized FF driver, it is not working.. WebDriver driver = new FirefoxDriver();
-
Hari Reddy almost 12 yearsTry not to use the latest firefox version and also make sure you are using all the necessary jars required to run selenium. Check this link - seleniumhq.org/download
-
Mohammed Akram almost 12 yearsTried downgrading the FF Version also, didn't help and also all the necessary jar files are added, It works in IE
-
Hari Reddy almost 12 yearsCan you tell me which all selenium jars you are using. Make sure you are using the Selenium Server Standalone jar - selenium.googlecode.com/files/selenium-server-standalone-2.21.0.jar
-
Mohammed Akram almost 12 yearsYes I was using selenium-server-standlaone-2.22.jar and I updated it to latest2.23.1 and it is working fine now.. Thanks for all the help.
-
Thom almost 9 yearsWhile this code is useful, a few words of explanation would make it even more useful to future readers.