Mohammed Akram
Mohammed Akram

Reputation: 165

WebDriver with Java code does NOT open Firefox and does nothing in Windows XP

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();
    }
}

Upvotes: 4

Views: 24680

Answers (4)

Anubhav Goel
Anubhav Goel

Reputation: 1

You can use the below code to fix this issue :-

    System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
    FiewfoxDriver fdr = new FirefoxDriver();

Upvotes: 0

Michal
Michal

Reputation: 3276

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);     

Upvotes: 1

Raphael Lacerda
Raphael Lacerda

Reputation: 21

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>

Upvotes: 2

Hari Reddy
Hari Reddy

Reputation: 3858

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.

Upvotes: 1

Related Questions