Created
January 26, 2011 22:22
-
-
Save purplejacket/797615 to your computer and use it in GitHub Desktop.
A Selenium "hello world" program to be run in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../test_helper' | |
require "selenium/client" | |
class HelloTest < ActiveSupport::TestCase | |
def setup | |
@verification_errors = [] | |
@selenium = Selenium::Client::Driver.new \ | |
:host => "localhost", | |
:port => 4444, | |
:browser => "*safari", | |
:url => "http://localhost:3000/", | |
:timeout_in_second => 60 | |
@selenium.start | |
@selenium.set_context("test_untitled") | |
end | |
def test_untitled | |
@selenium.open "/?network_id=1" | |
@selenium.click "open" | |
@selenium.type "email", "advertiser@gmail.com" | |
@selenium.type "password", "my_password" | |
@selenium.click "submit", :wait_for => :page | |
begin | |
assert @selenium.is_text_present("Results * for selenium rc") | |
rescue Test::Unit::AssertionFailedError | |
@verification_errors << $! | |
end | |
end | |
def teardown | |
# @selenium.stop | |
assert_equal [], @verification_errors | |
end | |
end | |
# |open|/selenium/setup| | |
# |open|/?network_id=1| | |
# |click|open| | |
# |type|email|advertiser@gmail.com| | |
# |type|password|my_password| | |
# |clickAndWait|submit| | |
# |clickAndWait|view-campaign-link| | |
# |type|quantity-298486374|400,000| | |
# |click|//a[@id='update-298486374']/span| | |
# |pause|5000| | |
# |assertTextPresent|$1,196.00| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try with this one:
require 'rubygems'
require 'selenium'
require 'selenium/server_manager'
require 'test/unit/testsuite'
require 'test/unit/ui/console/testrunner'
It's a minimap setup to get everything working, install Selenium gem and you're done.