1

In MacBook Pro, when I run the following Selenium, I am getting RuntimeException.

import com.thoughtworks.selenium.DefaultSelenium;

public class Test {

   public static void main(String[] args) {
           DefaultSelenium selenium=new DefaultSelenium("localhost", 4444,"*firefox ","http://");
           selenium.start();
           selenium.open("http://google.co.in");
           selenium.windowMaximize();
           selenium.type("gbqfq", "selenium");
           selenium.click("gbqfb");
   }

}

Exception:

Exception in thread "main" java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3 /blah/blah/firefox-bin
       at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:109)
       at Test.main(Test.java:8)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3 /blah/blah/firefox-bin
       at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
       at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
       at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
       at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
       at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
       ... 1 more

Please help me.. how to solve.

Tushar
  • 3,527
  • 9
  • 27
  • 49
user2541576
  • 67
  • 2
  • 7
  • 1
    Why aren't you using the `WebDriver`? Selenium RC (`DefaultSelenium`) should not be used anymore if possible. http://stackoverflow.com/questions/11535950/difference-between-selenium-rc-and-webdriver – LaurentG Aug 04 '13 at 14:45
  • have you tried using another webdriver ? It's pretty clear that selenium is unable to find firefox. Also, the code is pretty out-dated, try considering updating it. – coding_idiot Aug 06 '13 at 02:28

3 Answers3

0

You need to provide the firefox profile path so that selenium can use it to instantiate the browser.

OS X Firefox profile location

Selenium w/ Firefox Profile 1

Selenium w/ Firefox Profile 2

0

Try this:

DefaultSelenium ds = new DefaultSelenium(new WebDriverCommandProcessor("http://:",new
FirefoxDriver()));

// ds.start(); -- do not do this

ds.open("/pdm");

Akshat
  • 1
0

Give Selenium Path as shown Below:

->DefaultSelenium  selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "http://");
Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
Meena
  • 41
  • 3