24

I made then saved a test case with the Firefox extension "Selenium IDE".

Now I want to use command line to run this exported html file.

I try to follow this how-do-i-launch-the-selenium-ide-from-the-command-line-with-a-specific-test-case but it doesn't work.

Please help me.

Community
  • 1
  • 1
phuwanart
  • 507
  • 1
  • 5
  • 13

9 Answers9

42

You will need the Selenium RC which you can get from:
http://seleniumhq.org/download/

And Java 1.5 or higher (Download Java here)

1) Install Java
2) Unpack Selenium RC.
3) Open a cmd.exe window and go to the directory containing the Selenium Server (selenium-remote-control-1.0.1\selenium-server-1.0.1)
4) Run the command below:

java -jar selenium-server.jar -htmlSuite "*firefox" "http://10.8.100.106" "C:\mytestsuite\mytestsuite.html" "C:\mytestsuite\results.html"

This should run your test suite in Firefox and write the results to the html file. Obviously you will need to change the "http://10.8.100.106" argument to your own server (this might just be localhost / 127.0.0.1)

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
jmc
  • 813
  • 10
  • 18
  • he wants to run a specific test though – AutomatedTester Aug 06 '09 at 08:39
  • Ok, sorry I missed that little detail!

    Well in that case they should create a new testsuite HTML file containing just the single test html that they want to run. Probably just take an existing testsuite html file split it into a notiional header and footer parts and then write a simple piece of code to concatenate the header, the test name and the footer together, then run that through the command I gave in my answer.

    neokain> What language are you familiar with and I'll try and write a fuller example.
    – jmc Aug 06 '09 at 09:11
  • Is there a way to run test using already opened instance of Firefox? – Piotr Dobrogost Oct 30 '12 at 08:31
  • how to run test suite in slow mode – Rahul Sep 22 '14 at 08:02
  • @Rahul it might be better to ask another question, this one was answered 5 years ago! – jmc Sep 22 '14 at 10:23
  • i asked but nobody is answering it – Rahul Sep 22 '14 at 11:11
  • I think this no longer works with Selenium 3 (which requires a separate webdriver). `java -jar selenium-server-standalone-3.0.0-beta2.jar -help` does not return an -htmlSuite option – andrew lorien Aug 12 '16 at 00:58
3

It is possible to run individual test cases using Selenese Runner. You can specify a single test case file or a test suite as the unit to run.

zoomsthru
  • 39
  • 1
2

We should execute the SeleniumRC in using following command;

java -jar filename.jar

ex:

java -jar program1.jar

the program1 consist of the followings are:

  1. program1.class file
  2. Resource library file such as SeleniumRC Server.jar and Selenium Java client.jar file

This method is applicable for SeleniumRC execution. We can directly create the program1.jar file from eclipse using File->Export.

eeerahul
  • 1,629
  • 4
  • 27
  • 38
Hariharan
  • 21
  • 1
1

Here is an article that explains you step-by-step process of how to run Selenium RC application in Java.

Create a Java Selenium RC test script and executing the script

0

I have needed to do this before, and used the following:

  1. An Ant Build (complex)
  2. Creating a test runner class(a part of junit framework)class.

Most commonly we would run into build path errors while trying to run from cmd.

4444
  • 3,541
  • 10
  • 32
  • 43
user2062360
  • 1,323
  • 5
  • 16
  • 29
0

To be able to run in Chrome browser, you can use *chrome option instead of *firefox like below

java -jar selenium-server.jar -htmlSuite "*chrome" "http://localhost" "C:\testsuite\testsuite.html" "C:\testsuite\results.html"

Other browsers list include:

*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom

on session null

Ragavendra
  • 90
  • 5
0

If you want to run it from command prompt you may consider writing your selenium test in python. Make sure you have python installed if you are on windows. Mac will have python by default.

0

1) Running from CMD

java -cp "C:\ProjectX\Mortgage\bin;C:\Selenium_latest\selenium2.49.1\*;C:\Selenium_latest\selenium-2.49.1\libs\*" org.testng.TestNG C:\ProjectX\Mortgage\testng.xml

Run above command in C:\ProjectX\Mortgage

2) Create batch file name runner.bat

SET projectLocation=C:\ProjectX\Mortgage
CD %projectLocation%
SET classpath=%projectLocation%\bin;C:\Selenium_latest\selenium-2.49.1\*;C:\Selenium_latest\selenium-2.49.1\libs\*
java org.testng.TestNG %projectLocation%\testng.xml
PAUSE

3) Run the batch file by double clicking on it.

Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
0

Running test from CMD is quite easy.

Follow below steps

1- Go to home directory and Set class path

Home Directory > set classpath=Home Directory\bin; and press enter

Home Directory > set classpath=Home Directory\lib*; and press enter

2-Home-directory > java org,testng.TestNG testng.xml testng2.xml testng2.xml and hit enter

I have documented all steps here. Hope it will help. Cheers

Mukesh otwani
  • 821
  • 8
  • 11