Watir vs Selenium
October 28, 2009
Watir is a Ruby library that wraps the COM interface to Internet Explorer. COM is a long-standing Windows-based technology for making libraries accessible to various languages. This allows access to the Document Object Model (DOM) so it doesn’t matter where on the page an object exists, what matters is how you identify it (id, name, title, etc).
Selenium uses a unique mechanism for driving browsers. Selenium’s automation engine is written in JavaScript and runs inside a browser. The engine, called a browser bot, is embedded in a page that accesses the application under test in a separate frame. Because of cross-site scripting, Selenium’s browser bot has to be served from the same site as the application under test – requiring installation on the server.
Selenium supports a command language, called Selenese. Tests can be embedded in an HTML table, which will be read in by the browser bot and then executed.
Both tools run tests directly in a browser, and both do it in a way that allows the browser to be minimized while the tests are running, which means you don’t have to dedicate a machine to running tests.
Watir was designed to be easy to learn, it allows page elements to be identified by index, name, ID, value or adjacent text. Now Watir supports IE, Firefox,chrome,Safari with the help of Firewatir, SafariWatir,chrome Watir. Complaint: Watir is currently limited to IE browsers on Windows, Firewatir supports firefox browsers. So we need to write separate code for each and every browsers. But Selenium does in Single attempt.
Selenium was designed for breadth of coverage- multiple browsers and platforms. It was expected to be used by the same developers who built the application. Complaint: Selenium requires a server-side installation.
You can also express Selenium tests in a programming language, taking advantage of language-specific drivers that communicate in Selenese to the browser bot.
Reference: http://www.newsqa.com/watir-vs-selenium/
How to run Selenium RC with Ruby codes
October 12, 2009
1. Download seleniumRC from –> http://bit.ly/j_sel_rc
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. cmd prompt>gem install selenium-client
6. Open new command prompt and goto ruby program path.In Ex, c:\test>ruby code.rb
7. code.rb
require “selenium”
require “test/unit”
class Untitled < Test::Unit::TestCase
def setup
@verification_errors = []
if $selenium
@selenium = $selenium
else
@selenium = Selenium::SeleniumDriver.new(“localhost”, 4444, “*chrome”, “http://change-this-to-the-site-you-are-testing/”, 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”
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
Selenium On Rails
December 12, 2008
Getting Started
Selenium on Rails is the name of the Selenium product crafted specifically for Rails
developers and is distributed as a Rails plugin. It has been designed to work seamlessly
with the Rails testing environment and fixtures.
It’s easy to install Selenium on Rails and get started.
1. Install the core Selenium files needed by the plugin:
SAMPLE>gem install selenium
2. Install the Selenium on Rails plugin for a given project:
SAMPLE>ruby script/plugin install http://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails/
3. Generate the test directory and a test script:
SAMPLE>ruby script/generate selenium first.rsel
4. Start your Rails server in its test environment:
SAMPLE>ruby script/server -e test
5. Open the Selenium Test Runner in your browser:
http://localhost:3000/selenium
If your installation and setup succeeded, you see the Selenium Test Runner in your browser. You should also know that Selenium tests can be run from the command line and integrated into an automated suite of tests, but for demonstration purposes we will use the built-in web interface to execute our tests.
SAMPLE/test/selenium/first.rsel
setup
open ‘/’
assert_title ‘Ruby on Rails: Welcome aboard’
Run test in –> http://localhost:3000/selenium
For more reference –> http://seleniumhq.org/
Regards,
P.Raveendran
Selenium Grid
July 5, 2008
Selenium Grid:
Selenium Grid allows you to run Selenium tests in parallel, cutting down the time required for running acceptance tests to a fraction of the total time it currently takes. Run them all on a single machine (we’ve run up to 15 parallel processes on a laptop!) or on a server farm.
Technical Mumbo Jumbo:
Selenium Grid runs on top of Selenium Remote Control. Selenium is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser.
Step 1: Download selenium grid
Step 2: Setup your environment
In case you face any path issues then set path into your system following ways.
Way1:
Windows XP SP2 –> 1. Right click “My Computer”
2. Click “Advanced” tab
3. Click “Environment variables” button
4. In System variables –> click path –> Click edit
5. In edit system variable window –> go to end of line In “variable value” field –> [PASTE YOUR PATH]
Ex; C:\Program Files\Java\jdk1.6.0_06\bin;C:\grid\apache-ant-1.7.0-bin\apache-ant-1.7.0\bin;
6. Click ok for all 3 windows
Way2:
In command prompt,
c:\set path=%path%;”C:\grid\apache-ant-1.7.0-bin\apache-ant-1.7.0\bin;”
3. Run the demo