May 3, 2011

Run Selenium RC using Command Prompt

Downloading and Installing Selenium RC:
  • Go to http://seleniumhq.org/download/.
  • Under Selenium Server (formerly the Selenium RC Server) section you    can see the selenium server latest version.
  • Click on download, it will be redirected to selenium server download page.
  • Selenium server is a JAR file. Download selenium-server-standalone-2.ob3.jar.
  • Create a Folder selenium in “C” drive.
  • Paste the selenium-server-standalone-2.ob3.jar file in that folder.

Start  and Stop Selenium Server:

  • We need to be able to start and stop the Selenium Server.
  • We can do this at the command line:
  • Start:  (Command line)
  • java -jar selenium-server-standalone-2.0b3.jar
  • Stop: (Browser)
  • http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
Getting Started with Selenium/ Selenium RC steps:

  • Record your test case using Selenium IDE
  • Play your test case using selenium IDE itself to make sure that your test case works.
  • Export your recording test case - as html file.
  • Create a test suite.
  • Run your exported html test case using selenium rc
Steps:

  • Record a program using IDE:
  • Create a folder in any drive – Ex: C:\tests
Create folders:
  • We need to create two folders.
  • 1.To save our test suite and test case. (tests)
  • 2.To save results (results)
  • Using Selenium IDE record a test case and save it as .html in a tests folder.
  • Make sure your test run correctly.
Create a Test suite:
  • Create a test suite and save it in C:\tests folder
Run your scripts using selenium RC:

  • We can run our tests in any browser by using selenium RC.


Syntax:
java -jar selenium-server-standalone-2.0b3.jar -htmlSuite "*browser" "http://www.example.com" "c:\naga\tests\run.html" "c:\naga\results\results1.html“

RUN THE ABOVE COMMAND FROM COMMAND PROMPT:

Run this command from selenium directory.
Example:
C:\selenium>java -jar selenium-server.jar -htmlSuite "*iexplore" "http://www.google.com" "c:\naga\tests\run.html“ "c:\naga\results\results1.html"

Selenium Test Runner:

Results:






55 comments:

  1. Naga,
    Thanks for this useful blog.
    I am trying to execute from command line a selenium test written in java rather than recorded with SeleniumIDE. Do you happen to know an example for that?.
    Thank you,
    Sebastian.

    ReplyDelete
  2. Hi Sebastian,

    I have no idea about that. But i knew how to run Java script from IDE

    Thanks,
    Naga

    ReplyDelete
  3. Hi, Can you tell me how to stop the selenium server from Command prompt

    regards,
    shaleni

    ReplyDelete
  4. Hello thank you for this and i have managed to get the RC to run my scripts in IE after following these steps.

    I am having problems with the results and I am getting time out error in results even though it seems to be working. Do you know why?

    thanks

    ReplyDelete
  5. Even i'm getting time out error issue. Default time out for each command is 3000ms so is there any way to increase this time out ? Please help me in this way.

    ReplyDelete
    Replies
    1. you can use command settimeout() in your test case to change the default timeout.

      Delete
  6. This is wonderful post.I never seen like this information in any website or document or materials.

    Thanks for brief and step wise description on RC.

    ReplyDelete
  7. Thanks !!!!- Milton

    ReplyDelete
  8. Hi Naga,
    Can you please comment how to run Java script from IDE

    -vamsi

    ReplyDelete
  9. I mean how to run it from Command prompt as I am trying to execute as Junit script from command line prompt

    ReplyDelete
  10. hi
    when i start the selenium server from command prompt it always display unable to access java-jar selenium server...can u help me to fix this problem

    ReplyDelete
    Replies
    1. Prabhu.....

      You need to save selenium server in particular where you can access easily.
      I saved it in C: to access in easy way.
      Rename your server jar file name to Selenium-server or something else...

      Now open Command prompt and type cd/ and enter
      then C:
      then use command like "java -jar selenium-server.jar

      Now it will start selenium server :)

      Hope it will be usefull :)

      Delete
  11. Hi Naga,

    I want to know how the testSuite is created. Please let me know. coz i stuck in running the script,

    ReplyDelete
  12. Hi Naga ,

    I tried to run this command on comamnd line to run test suite on google chrome


    java -jar selenium-server-standalone-2.6.0.jar -htmlSuite "*googlechrome" "http://www.google.com" "C:\wamp\www\selenium\test\googleSuite.html" "C:\wamp\www\selenium\result\result_googlechrome19sep1.html"

    that command is working fine on IE but its just opening in chrome but not testing the test cases.
    Could you please help me in this?
    Thanks,
    Anand(anandshahil11@gmail.com)

    ReplyDelete
  13. When i running the iexplore.
    java -jar selenium-server-standalone-2.7.0.jar -htmlSuite "*iexplore" "http://google.co.in" "c:\seleniumTesting\suit.html" "c:\seleniumTesting\report\report.html
    i have a one pop up box is came it shown An errr has occured in the script on this page.
    pop-up block enabled


    Thanks
    venu

    ReplyDelete
  14. i am getting the same message as mentioned by venu..please help

    ReplyDelete
  15. Hi Venu,

    That is the problem with IE.u need to diable the security check..for more details pls go through the post..

    http://testerinyou.blogspot.com/2011/03/error-while-running-selenium-scripts-on.html


    Thanks,
    Naga

    ReplyDelete
  16. for me it is giving an error that java is not recognized as an internal and external comamnd.

    ReplyDelete
    Replies
    1. Install java in you system as well as selenium server

      Delete
  17. Please help me what do i need to do when "java not found as an ext and int command" is received. I need to start the selenium server.

    ReplyDelete
  18. Thanks dude for below information..........

    "http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"

    ReplyDelete
  19. I have did everything what you have mentioned, but still i am not able to run my script.
    In IE and firefox - i am getting message that


    And for iexploreproxy - 14:26:08.830 INFO - Killing Firefox...
    14:26:08.832 WARN - Firefox seems to have ended on its own (did we kill the real
    browser???)

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
    Timestamp: Tue, 7 Feb 2012 08:55:05 UTC
    Message: Access is denied.
    Line: 184
    Char: 9
    Code: 0
    URI: http://www.google.com/selenium-server/core/scripts/selenium-testrunner.js

    ReplyDelete
    Replies
    1. for iexploreproxy - Webpage error details

      User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
      Timestamp: Tue, 7 Feb 2012 08:55:05 UTC
      Message: Access is denied.
      Line: 184
      Char: 9
      Code: 0
      URI: http://www.google.com/selenium-server/core/scripts/selenium-testrunner.js

      Delete
  20. Hi Naga,

    Its a wonderful post.
    Please keep sharing such posts.

    ReplyDelete
  21. Thanks for this post. But I encountered a problem when run the command line with browser "*firefox". The testing stopped after the first case run and never run the rest test cases.
    Anybody has such experience? Thanks ahead.

    ReplyDelete
  22. Nice posting, I subsribe your feed. Keep it up with fresh idea.

    ReplyDelete
  23. @naga, i am not able to execute conditional statements like gotoif. It is giving me error as unknown command..

    ReplyDelete
  24. Hi,
    I have tried everything, and my command line is not giving me any error either. But it just opens a blank firefox page and its not running my testsuite!!
    I am using following path :
    java -jar selenium-server-standalone-1.0.3.jar -htmlSuite "*firefox" "http://www.google.co.uk" "c:\data\tsel\testsuite.html" "c:\data\sel\results.html“

    ReplyDelete
  25. Hi
    I am getting error message while running the command in command prompt as
    " Not enough command line arguments for -html suite
    -html suites requires you to specify
    * browserString ( e.g."*firefox")
    * startURL (e.g. "http:/www.google.com")
    * suiteFile (e.g. c:\absolute\path\to\my\HTMLSuite.html)
    * resultFile (e.g."c:\absolue\path\to \my\results.html") "

    Entered command as
    java -jar selenium-server-standalone-2.25.0.jar -htmlSuite "*firefox""http://http://www.rediff.com" "c:\C:\Users\priya\Desktop\Seaonal_selenium\priyatest.html""c:\C:\Users\priya\Desktop\Seaonal_selenium\results.html"

    in command promt

    Please anyone help me regarding this.
    mail id: rajpurn@gmail.com

    ReplyDelete
  26. Hi, can anyone tell me if there is a way of re-directing the display of the browser to another machine? basically I want the browser to run on a different environment from the RC server is installed.

    ReplyDelete
  27. hey can some body help me

    ReplyDelete
  28. help......
    ive only just started learning selenium#
    ive been trying to start server from cmd with the following command java-jar selenium-server.jar. its comming with the error saying bindexception selenium server is running on port 4444
    and also what is socket listener0.000.00444

    ReplyDelete
  29. how to run selenium script in google chrome by writing code in command prompt??

    ReplyDelete
  30. this is my first comments

    ReplyDelete
  31. Hi, how to setup selenium with eclipse

    ReplyDelete
  32. Hi, how to setup selenium with eclipse

    ReplyDelete
    Replies
    1. hi
      follow mentioned below steps for setup
      1.Create a Java Project
      A blank project explorer will be opened on closing welcome window.
      The next step is to create a java project in eclipse. Choose File – New – Other.
      Choose Java Project option in the new project wizard opened and click on Next.
      Enter a name for project and check if Java Runtime Environment (JRE) is set for the project. If not, then choose any JRE available for use an execution environment JRE dropdown. Click on Finish button

      A confirm dialog on setting association to Java perspective will be displayed. Check remember my decision checkbox and click on Yes button.
      Once a new project is created, the project explorer will be displayed with new project created along with JRE chosen for it.

      2.Configure Build Path

      The next step is to configure build path to the newly created project. In this step, we will associate the selenium server JAR file to its respective project.

      Right click on newly created java project – Choose Build Path – Choose Configure Build Path…
      Click on Libraries tab in opened project properties dialog. Click on Add External JARs button and choose selenium server jar from its respective location.
      serverjar

      The final libraries tab will contain selenium server selected along with JRE set

      for more refer link

      http://diveintotesting.com/2013/02/19/selenium-web-driver-setup-using-eclipse-and-java/

      Delete
  33. Hi, how to setup selenium with eclipse

    ReplyDelete
  34. Hi I got error as Time out 30000ms. so please tell me how can i solve it??

    ReplyDelete
  35. devising use of this method as a natural symptoms such as Itch or discharge.
    many women familiar dispatch with candida but this isn't e'er the lado os colares coloridos ou grandes.
    They are both all remedies for Yeast Infection is yoghourt, garlic, and many others
    out In that location. You may considerably get a complete that likewise vernacular during pregnancy.
    refer a Medical professional if you are for the Utmost 12 hours, this can be an indicant at possible IV liquid permutation.



    my web-site photos of yeast infections

    ReplyDelete
  36. Oh my goodness! Incredible article dude! Many thanks, However I am having issues with your RSS.
    I don't know why I cannot subscribe to it. Is there anybody getting identical RSS issues? Anybody who knows the solution will you kindly respond? Thanx!!

    Here is my web site ... eschelongames.com

    ReplyDelete
  37. After exploring a few of the articles on your website, I
    really like your way of writing a blog. I book marked it to my bookmark webpage list and will be checking back
    in the near future. Take a look at my website too and let me know how you feel.


    Here is my page workouts for vertical

    ReplyDelete
  38. Wow, that's what I was searching for, what a stuff! present here at this weblog, thanks admin of this website.

    Feel free to surf to my webpage ... https://Students.Ee.Port.Ac.uk/ece50340/fridgebook/ChastitylvAlbrittonjm

    ReplyDelete
  39. It's actually a cool and helpful piece of info. I am happy that you just shared this helpful info with us. Please stay us up to date like this. Thanks for sharing.

    my web blog: http://verticaljump.einfohound.com/vertical-jump-program-reviews/increase-your-vertical-jump-best-programs-rated

    ReplyDelete
  40. I would like to thank you for the efforts you have put in
    penning this website. I am hoping to view the same
    high-grade blog posts from you later on as well. In fact,
    your creative writing abilities has inspired me to
    get my own blog now ;)

    My webpage: exercises to increase vertical jump

    ReplyDelete
  41. The Lego figure has an evil face, a detailed body with a cape and removable helmet as well as the inevitable red lightsaber.
    With all of the technological advances made by toy makers and manufacturers,
    the word "toy" means something completely different than it
    did to the past generations. But are you aware that Lego also produce electric toy trains
    and that they not only have trains, but also locomotives, track, rolling stock, train stations, signal houses and a whole load of other track side buildings and they all have
    the logo construction theme running through them.


    Also visit my blog post; compendium.itcilo.org

    ReplyDelete
  42. without recording can we write script for selenium Rc if yes then what is syntax for that

    ReplyDelete
  43. without recording can we write script for selenium Rc if yes then what is syntax for that

    ReplyDelete
  44. hi, I am using selenium RC command . java -jar /home/selenium/selenium.jar -timeout 60000 -browserTimeout 60000 -htmlSuite '*firefox' http://localhost /opt/selenium/AutomationTS_4.html /var/TestResult.html -firefoxProfileTemplate "/root/.mozilla/firefox/fmdhqc12.selenium" But , i am getting timeout error(30000secs). please help me to get resolve this issue

    ReplyDelete
  45. Very useful blog .Simple language used and straight to the point. Keep up the good work

    ReplyDelete
  46. It fun to have a content like this really worth to read it
    PlSQL Training

    ReplyDelete
  47. in command prompt not able to access the server .message is there "java not found as an ext and int command" is received

    ReplyDelete