11

I got Selenium IDE, followed this post, got to

python test_default_server.py

and it complains Firefox is not in my path:

Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3c:\blah\firefox.exe

I could change my PATH environment variable, but I'd rather pursue the local config option they are mentioning ("explicitly specify a path"). How do I do that? What does the "*firefox3c" refer to?

Selenium 1.0.1, Python 2.5, Windows XP.

dfrankow
  • 20,191
  • 41
  • 152
  • 214

8 Answers8

16

You have to use the following string when you instantiate selenium instead of just "*firefox":

"*firefox C:\\Program Files\\Mozilla Firefox\\firefox.exe"

Notice: I'm not sure that path is correct, but it should be a similar one.

Update: Where do you instantiate your browser? By the tags in the question I suppose you're a python guy:

def setUp(self):
    self.verificationErrors = []
    self.selenium = selenium("localhost", 4444, "*firefox C:\\Program Files\\Mozilla Firefox\\firefox.exe", "http://change-this-to-the-site-you-are-testing/")
    self.selenium.start()
slartidan
  • 20,403
  • 15
  • 83
  • 131
Santi
  • 4,428
  • 4
  • 24
  • 28
  • where do you instantiate selenium? You mean at the command line? Is it a command-line arg? – dfrankow Aug 29 '09 at 17:13
  • 1
    Notice that you'll neet to add r as a prefix to "*firefox..." as it - r"*firefox C:\Program Files\Mozilla Firefox\firefox.exe". This fixed the problem for me. – Jonathan Livni Jun 26 '10 at 16:45
  • One reason this doesn't work is that Python uses \ to escape characters. You need to make it /, or \\. – boatcoder Dec 14 '10 at 16:27
  • The path "*firefox C:\Program Files\Mozilla Firefox\firefox.exe" should be updated with correct answer to avoid unnecessary bug finding, either r"*firefox C:\Program Files\Mozilla Firefox\firefox.exe" or "*firefox C:/Program Files/Mozilla Firefox/firefox.exe" – OnesimusUnbound Feb 22 '11 at 00:35
  • Apparently this issue has resurfaced for Windows 7 64-bit in the most recent 2.0 beta: http://jira.openqa.org/browse/SEL-737 – Noyo Feb 22 '11 at 20:02
  • I apologize I have not tested the solution because I do not have the environment to test it anymore, I'd have to recreate it. – dfrankow Apr 04 '11 at 21:29
2

If on C# editor, use the following string:

selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\\Program Files\\firefox.exe", "http://www.google.com/");

Note: use an extra back slash before Program Files and firefox.exe, since a single backslash becomes an unrecognized escape sequence.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Pallavi
  • 21
  • 1
1

For Java Solution using Selenium Webdriver, you can import the below class:

import org.openqa.selenium.firefox.FirefoxBinary; 

and use the code snippet below to instantiate a new driver by explicitly specifying the path to the firefox.exe in your local system.

DesiredCapabilities browserCapabilities = DesiredCapabilities.firefox();
FirefoxBinary ffbinary = new FirefoxBinary(new File("C:\Program Files (x86)\Mozilla Firefox\firefox.exe"));
FirefoxProfile ffprofile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(ffbinary, ffprofile, browserCapabilities);

Note: You may need to replace "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" with the path that points to firefox.exe on your local machine.

1
selenium("localhost", 4444, "*firefox C:\Program Files\Mozilla Firefox\firefox.exe", "http://change-this-to-the-site-you-are-testing/")

Worked in Java.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Mathura
  • 11
  • 1
1

This helps very much. setUp("http://localhost:8080/BingDemo/BingDriver.html", "*firefox C:\Program Files (x86)\Mozilla Firefox\firefox.exe");

However, replace all occurrences of \ with \\ in *firefox C:\Program Files (x86)\Mozilla Firefox\firefox.exe

Additionally, you could point your PATH to in environmental variables to mozilla.exe

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Leon
  • 11
  • 1
0

The *firefox etc are the keys for which browser to use to run the tests.

There is a long list of them at How to run Google Chrome with Selenium RC? - so you can target Firefox v2 (*firefox2), Firefox v3 (*firefox3), Google Chrome (*googlechrome) etc

Community
  • 1
  • 1
Jane
  • 1,953
  • 1
  • 20
  • 27
  • in the initialisation, i.e. selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://stackoverflow.com"); Replace the "*chrome" bit with any of those keys to target a different browser – Jane Sep 03 '09 at 12:13
0

I found it worth useful...

Selenium selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\Program Files (x86)\Mozilla Firefox\firefox.exe", "http://gmail.com");
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
0

This helps very much.

setUp("http://localhost:8080/BingDemo/BingDriver.html", "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
j0k
  • 22,600
  • 28
  • 79
  • 90
Leon
  • 11
  • 1