How to run Selenium RC with Ruby codes

1. Download seleniumRC from –> http://seleniumhq.org

2. Unzip the file

3. commans prompt>java -version  –> Version should grater than 1.6.0_5

4. command prompt go to –> C:\selenium-remote-control-1.0.1\selenium-server-1.0.1>java -jar  selenium-server.jar

Now Selenium runs on 4444 port.

5.  a)Download and install Ruby from http://ruby-lang.org/en/downloads/

b) cmd prompt>gem install selenium-client

or

i) Go to http://rubygems.org/gems/selenium-client

ii) Click Download and save the GEM file in C:\ruby\bin\

iii) Cmd Propmt –> C:\ruby\bin>gem install GEMNAME

 

6. Open new command prompt and goto ruby program path.In Ex, c:\test>ruby code.rb

7.  code.rb

require “selenium/client”
require “test/unit”

class Untitled < Test::Unit::TestCase
def setup
@verification_errors = []
if $selenium
@selenium = $selenium
else
@selenium = Selenium::Client::Driver.new(“localhost”, 4444, “*chrome”, “http://jazzez.wordpress.com/&#8221;, 10000);
@selenium.start
end
@selenium.set_context(“test_untitled”)
end

def teardown
@selenium.stop unless $selenium
assert_equal [], @verification_errors
end

def test_untitled
@selenium.open “/”
@selenium.click “link=jazzez-news.exe released (using Mechanize – ruby gem)”
@selenium.wait_for_page_to_load “30000”
@selenium.click “link=exact:http://bit.ly/j_news_demo&#8221;
end
end

8. Selenium RC will give some outputs in new firefox window.

Any more details need then just ping me at jazzezravi@gmail.com

Advertisements

5 thoughts on “How to run Selenium RC with Ruby codes

  1. Naveen says:

    HI

    I am Naveen.I had learnt ,how to run selenium IDE & selenium RC.The main thing is how to generate a Test Report after the running the test Succesfully.And another thing is How to run Selenium Core and when it is useful .And suggest me some more open source tools for testing .Net and Java Projects ………………………..

    Try to help me…..

    Thanks
    Naveen

  2. KL Aziz says:

    Hi Ravee,
    It is really nice to know the difference and advantage between Watir and Selenium.
    Thank you for your hard work and info sharing.
    Wish you the very best!

  3. sanjeev says:

    hi ravee,

    Can you help me? How to change “def test_untitled” to some other name eg. def my_test

    How to define multiple tests and set their context in a single test.

  4. Tae says:

    Hi all,

    I’m studying Selenium RC that use by Ruby.
    When I run “java -jar selenium-server.jar” command. It shows warning as

    “Failed to start: SocketListener0@0.0.0.0:4444
    Exception in thread “main” java.net.BindException: Selenium is already running on port 4444. Or some other service is.”

    From the warning, it could work or not.

    Thank you so much.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s