9

I'm on Windows, and I want to launch Firefox and the Selenium IDE with a specified test case loaded and ready to play back.

I've got as far as:

>"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content"

which launches Firefox and the IDE, but I don't know enough about the Selenium IDE or Chrome to get any further. I'd expect something like:

>"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content?test=foo.html"

to be supported, but I can't find the right incantation.

As background, I'm generating test case templates from a Swing application and want to just punt them into Firefox for modification and execution with a single button-press. If there's an easier way to do that than Runtime.getRuntime.exec(theAbove) then I'm all ears.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
user60401
  • 668
  • 1
  • 4
  • 6
  • I'm a bit confused about the need to have a human edit them first. What is your ultimate goal? – Mark Erdmann Jul 23 '09 at 04:17
  • Sorry, can't say. Suffice to say that yes, I really do need to have a human edit them before they are run, to add steps that are circumstance-dependent. The Swing app generates a bunch of boilerplate to save time. – user60401 Jul 23 '09 at 12:29
  • This might be a good reference: http://kb.mozillazine.org/Command_line_arguments – Rimian Feb 04 '11 at 04:49

2 Answers2

10

You are close. Selenium has a built-in page to auto load and execute tests from a test-suite called TestRunner.html. You can invoke it like follows :

C:\Program Files\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content/selenium-core/TestRunner.html?baseUrl=http://[BASEURL]&test=file:///[TESTSUITE-PATH]&auto=false"

This will fireup firefox with all tests from the test-suite at the specified path loaded up and waiting to execute in a single button press.

For example

After creating a couple of selenium tests, save the test cases as testcase1.html and testcase2.html in a folder say c:\tests.

Save the test suite as testsuite.html in the same folder. Now you can launch these suite of tests with the below command line :

C:\Program Files\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content/selenium-core/TestRunner.html?baseUrl=http://localhost&test=file:///C:\tests\testsuite.html&auto=false"

You should have the tests loaded up in firefox ready to execute.

If you change the above url to have auto parameter to true, then it will run the tests as well after launch.

&auto=true

EDIT :

Updated baseurl argument to proper case sensitive form: baseUrl

Updated path to TestRunner.html to: chrome://selenium-ide/content/selenium-core/TestRunner.html

Jordan Noel
  • 220
  • 2
  • 4
  • 14
Pradeep
  • 4,099
  • 4
  • 31
  • 45
  • Sorry, I should have been clearer. I can't need to run the tests immediately. They need some human editing first, which means I need to load them up into the IDE before I run them. I don't see how to get from the TestRunner to the IDE. – user60401 Jul 21 '09 at 12:53
  • 1
    Bah, submitted too early. I meant to say "I can't run the tests immediately." – user60401 Jul 21 '09 at 12:54
  • I have looked at the XUL files that make up the selenium-IDE in the extension xpi and they aren't loading the test files as URL parameters. so if you are up to it you can modify the XUL and write some script to read from URL params and then invoke it like above. – Pradeep Jul 30 '09 at 12:17
  • yes it is working but can i know how to get the results using this? – Rahul Sep 19 '14 at 06:08
6

If you want to run a testsuite with firefox from the commandline, you have to start run java, not firefox. Like this:

C:\Program Files (x86)\Java\jre6\bin\java.exe" -jar c:\seltest\selenium-server-standalone-2.18.0.jar -htmlSuite "*firefox" "http://127.0.0.1" "c:\seltest\mytestsuite.html" "c:\seltest\logs\results-firefox.html" -port 5555

-- Freek Borgerink

Tisho
  • 8,320
  • 6
  • 44
  • 52
  • Maybe this is no longer supported in Selenium 3 (which requires a separate webdriver). `java -jar selenium-server-standalone-3.0.0-beta2.jar -help` does not return an -htmlSuite option, and your commandline returns an exception – andrew lorien Aug 12 '16 at 00:35