开发者

Initial steps to get up and running with Selenium RC and tests written in Ruby?

开发者 https://www.devze.com 2023-02-19 17:27 出处:网络
Can someone tell me the exact steps (be specific) to test (write tests and then execute them) a website through Firefox using Selenium RC and the Ruby programming开发者_如何学C language?

Can someone tell me the exact steps (be specific) to test (write tests and then execute them) a website through Firefox using Selenium RC and the Ruby programming开发者_如何学C language?

I'm new to this and have only done it with Java, Eclipse, and JUnit 4 (and Selenium RC + IDE of course). I'm looking for steps similar to what it took for me to get it up and running with Java.

To get up and running with Java I did the following:

  1. Created new Java project in Eclipse.
  2. To this projected I added selenium-java-client-driver.jar, selenium-server.jar, and Junit4 Library.
  3. Using Selenium IDE I created a test and exported it in the Java language.
  4. I created a class in my Java project (in Eclipse) and imported this code; which needed some tweeking.
  5. I then click on the "Run " in eclipse and it works great.

Can someone give me comparable steps to get up and running with Ruby and any IDE?

Thank you


I'm going to start from the beginning:

  1. Install Ruby - If you're on windows, you can go to rubyinstaller.org and download an installer.. For other OS's, you may already have it installed or have some form of method to install. I don't know those methods, unfortunately.
  2. Install Selenium. If you're starting with a new project, use Selenium 2, which is still in beta, but which has a new interface that avoid some of the problems in Selenium 1 (like no cross-domain testing). To do this, go to a terminal shell or a command prompt and type 'gem install selenium-webdriver'.
  3. Start a test - you can record it in IDE and convert to Ruby (though that will still be Selenium 1's interface) or code it directly in a text file or an IDE (I use NetBeans Ruby for my tests). The basic code you want is:

    require 'selenium-webdriver'

    @driver = Selenium::WebDriver.for :firefox ' or :ie or :chrome or any of the other browsers @driver.navigate.to 'http://www.google.com'

    element = @driver.find_element :name, 'q' 'Not sure of this syntax - I have this wrapped in my code element.send_keys "Selenium"

Documentation is here: API docs - Notes


Okay, figured it out.

  1. Install ruby.
  2. Install selenium ide on FF
  3. DL and run the selenium server
  4. record a test in the selenium IDE for FF and export it as a ruby file
  5. open command line with ruby (confirm by typing "ruby -v") and navigate to this newly exported ruby file
  6. run "gem install selenium-client"
  7. "ruby your_file_name.rb". And that's it!
0

精彩评论

暂无评论...
验证码 换一张
取 消