Created
March 27, 2013 14:55
-
-
Save Isxida/5254826 to your computer and use it in GitHub Desktop.
yup...moar tests
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 "selenium-webdriver" | |
require "rspec" | |
include RSpec::Expectations | |
describe "SegundoCU" do | |
before(:each) do | |
@driver = Selenium::WebDriver.for :firefox | |
@base_url = "http://localhost:3000/lapiceros" | |
@accept_next_alert = true | |
@driver.manage.timeouts.implicit_wait = 30 | |
@verification_errors = [] | |
end | |
after(:each) do | |
@driver.quit | |
@verification_errors.should == [] | |
end | |
it "test_segundo_c_u" do | |
@driver.get(@base_url + "/lapiceros") | |
@driver.find_element(:link, "Edit").click | |
@driver.find_element(:id, "lapicero_nombre").clear | |
@driver.find_element(:id, "lapicero_nombre").send_keys "Pilot Frixion Gem Red FX-2" | |
@driver.find_element(:id, "lapicero_color").clear | |
@driver.find_element(:id, "lapicero_color").send_keys "Red tirando para marrón" | |
Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "lapicero_created_at_1i")).select_by(:text, "2003") | |
Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "lapicero_created_at_2i")).select_by(:text, "August") | |
Selenium::WebDriver::Support::Select.new(@driver.find_element(:id, "lapicero_created_at_3i")).select_by(:text, "23") | |
@driver.find_element(:name, "commit").click | |
@driver.find_element(:link, "Back").click | |
end | |
def element_present?(how, what) | |
@driver.find_element(how, what) | |
true | |
rescue Selenium::WebDriver::Error::NoSuchElementError | |
false | |
end | |
def verify(&blk) | |
yield | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
def close_alert_and_get_its_text(how, what) | |
alert = @driver.switch_to().alert() | |
if (@accept_next_alert) then | |
alert.accept() | |
else | |
alert.dismiss() | |
end | |
alert.text | |
ensure | |
@accept_next_alert = true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment