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:
- Created new Java project in Eclipse.
- To this projected I added selenium-java-client-driver.jar, selenium-server.jar, and Junit4 Library.
- Using Selenium IDE I created a test and exported it in the Java language.
- I created a class in my Java project (in Eclipse) and imported this code; which needed some tweeking.
- 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:
- 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.
- 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'.
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.
- Install ruby.
- Install selenium ide on FF
- DL and run the selenium server
- record a test in the selenium IDE for FF and export it as a ruby file
- open command line with ruby (confirm by typing "ruby -v") and navigate to this newly exported ruby file
- run "gem install selenium-client"
- "ruby your_file_name.rb". And that's it!
精彩评论