-
-
Save ivaravko/1133659 to your computer and use it in GitHub Desktop.
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 "selenium/rspec/spec_helper" # where is this coming from? what does it do? (jari) | |
require "spec/test/unit" # this looks outdated - should just be require "rspec" (jari) | |
describe "base.sel" do | |
before(:all) do | |
@verification_errors = [] | |
@driver = Selenium::WebDriver.for :firefox | |
@driver.manage.timeouts.implicit_wait = 30 | |
end | |
before(:each) do | |
#@selenium_driver.start_new_browser_session | |
end | |
append_after(:each) do | |
@driver.quit | |
@verification_errors.should == [] | |
end | |
it "test_base.sel" do | |
# open | file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm | | |
@driver.get "file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm" | |
# addSelection | name=num2 | 10 | |
# ERROR: Caught exception [ERROR: Unsupported command [addSelection]] | |
# assertAttribute | id=text5@style | visibility: hidden; | |
@driver.find_element(:id, "text5").attribute(:style).should == "visibility: hidden;" | |
# assertBodyText | glob:*Checkboxen* | | |
@driver.find_element(:tag_name, "BODY").text.should =~ /^[\s\S]*Checkboxen[\s\S]*$/ | |
# assertChecked | name=monkeys | | |
@driver.find_element(:name, "monkeys").should be_selected | |
# assertCssCount | css=input | 10 | |
@driver.find_elements(:css, "input").size.should == 10 | |
# assertEditable | name=etext | | |
# ERROR: Caught exception [ERROR: Unsupported command [isEditable]] | |
# assertElementNotPresent | id=Text8 | | |
begin | |
@driver.find_element(:id, "Text8") | |
fail "should not have found element" | |
rescue Selenium::WebDriver::Error::NoSuchElementError | |
# all good | |
end | |
# assertElementPresent | id=disabled | | |
@driver.find_element(:id, 'disabled') | |
# assertLocation | file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm | | |
@driver.current_url.should == "file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm" | |
# This is wierd, everything is true!! | |
# assertNotAttribute | name=dtext@disabled | sss | |
@driver.find_element(:name, "dtext").attribute(:disabled).should != "sss" | |
# This is wierd, everything is true!! | |
# assertNotBodyText | glob:*checkboxen* | | |
@driver.find_element(:tag_name, "BODY").text.should !~ /^[\s\S]*checkboxen[\s\S]*$/ | |
# assertNotChecked | name=elephants | | |
@driver.find_element(:name, "elephants").should_not be_selected | |
# This is wierd, everything is true!! | |
# assertNotCssCount | css=input | 9 | |
@driver.find_elements(:css, "input").size.should != 9 | |
# assertNotEditable | name=dtext | | |
# ERROR: Caught exception [ERROR: Unsupported command [isEditable]] | |
# assertNotLocation | url here | | |
@driver.current_url.should != "url here" | |
# assertNotTable | css=#table1.2.1 | r2c2 | |
# ERROR: Caught exception [ERROR: Unsupported command [getTable]] | |
# assertNotText | css=#text_tests | regexp:.*Text2.* | |
@driver.find_element(:css, "#text_tests").text.should !~ /.*Text2.*/ | |
# assertNotTitle | page_for_formatter_test_dont_match | | |
@driver.getTitle.should != "page_for_formatter_test_dont_match" | |
# type | name=etext | start msg | |
@driver.find_element(:name, "etext").clear | |
@driver.find_element(:name, "etext").send_keys "start msg" | |
# next cmd is an valid example where the the value param is supposed to be empty | |
# assertNotValue | name=etext | | |
@driver.find_element(:name, "etext").attribute(:value).should == "" | |
# assertNotVisible | id=text2 | | |
@driver.find_element(:id, "text2").should_not be_displayed | |
# assertNotXpathCount | //input | 9 | |
@driver.find_elements(:xpath, "//input").size.should != 9 | |
# assertText | css=#text_tests | regexp:Text1 | |
# *This is a test of the open command. | |
@driver.find_element(:css, "#text_tests").text.should =~ /Text1 | |
*This is a test of the open command./ | |
# type | name=etext | test msg | |
@driver.find_element(:name, "etext").clear | |
@driver.find_element(:name, "etext").send_keys "test msg" | |
# assertValue | name=etext | test msg | |
@driver.find_element(:name, "etext").attribute(:value).should == "test msg" | |
# assertVisible | name=dtext | | |
@driver.find_element(:name, "dtext").should be_displayed | |
# assertXpathCount | //input | 10 | |
@driver.find_elements(:xpath, "//input").size.should == 10 | |
# check | name=elephants | | |
# ERROR: Caught exception [ReferenceError: ifCondition is not defined] | |
# uncheck | name=elephants | | |
# ERROR: Caught exception [ReferenceError: ifCondition is not defined] | |
# click | name=wombats | | |
@driver.find_element(:name, "wombats").click | |
# echo | test msg | | |
p "test msg" | |
# open | file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm | | |
@driver.get "file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm" | |
# pause | 1000 | | |
sleep 1 | |
# refresh | | | |
@driver.navigate.refresh | |
# submit | css=#form1 | | |
@driver.find_element(:css, "#form1").submit | |
# type | name=etext | test msg | |
@driver.find_element(:name, "etext").clear | |
@driver.find_element(:name, "etext").send_keys "test msg" | |
# select | name=num2 | index=2 | |
# ERROR: Caught exception [ERROR: Unsupported command [select]] | |
# assertNotSomethingSelected | name=num2 | | |
# ERROR: Caught exception [ERROR: Unsupported command [isSomethingSelected]] | |
# assertTable | css=#table1.2.1 | r2d2 | |
# ERROR: Caught exception [ERROR: Unsupported command [getTable]] | |
# goBack | | | |
@driver.navigate.back | |
# close | | | |
@driver.close | |
# verifyAttribute | id=text5@style | visibility: hidden; | |
begin | |
@driver.find_element(:id, "text5").attribute(:style).should == ("visibility: hidden;") | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyBodyText | glob:*Checkboxen* | | |
begin | |
@driver.find_element(:tag_name, "BODY").text.should =~ /^[\s\S]*Checkboxen[\s\S]*$/ | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyChecked | name=monkeys | | |
begin | |
@driver.find_element(:name, "monkeys").should be_selected | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyCssCount | css=input | 10 | |
begin | |
@driver.find_elements(:css, "input").size.should == 10 | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyEditable | name=etext | | |
# ERROR: Caught exception [ERROR: Unsupported command [isEditable]] | |
# verifyElementNotPresent | id=Text8 | | |
begin | |
locator = {:id => "Text8"} | |
@driver.find_element(locator) | |
@verification_errors << RuntimeError.new("expected element #{locator.inspect} to not be present") | |
rescue Selenium::WebDriver::Error::NoSuchElementError | |
# all good | |
end | |
# verifyElementPresent | id=disabled | | |
begin | |
@driver.find_element(locator) | |
rescue Selenium::WebDriver::Error::NoSuchElementError => ex | |
@verification_errors << ex | |
end | |
# verifyLocation | file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm | | |
begin | |
@driver.current_url.should == "file:///E:/Dev/Selenium/Formatter-Tests/testaut.htm" | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# This is wierd, everything is true!! | |
# verifyNotAttribute | name=dtext@disabled | sss | |
begin | |
@driver.find_element(:name, "dtext").attribute(:disabled).should != "sss" | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# This is wierd, everything is true!! | |
# verifyNotBodyText | glob:*checkboxen* | | |
begin | |
@driver.find_element(:tag_name, "BODY").text.should !~ /^[\s\S]*checkboxen[\s\S]*$/ | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotChecked | name=elephants | | |
begin | |
@driver.find_element(:name, "elephants").should_not be_selected | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# This is wierd, everything is true!! | |
# verifyNotCssCount | css=input | 9 | |
begin | |
@driver.find_elements(:css, "input").size.should == 9 | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotEditable | name=dtext | | |
# ERROR: Caught exception [ERROR: Unsupported command [isEditable]] | |
# verifyNotLocation | url here | | |
begin | |
@driver.current_url.should != "url here" | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotTable | css=#table1.2.1 | r2c2 | |
# ERROR: Caught exception [ERROR: Unsupported command [getTable]] | |
# verifyNotText | css=#text_tests | regexp:.*Text2.* | |
begin | |
@driver.find_element(:css, "#text_tests").text.should !~ /.*Text2.*/ | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotTitle | page_for_formatter_test_dont_match | | |
begin | |
@driver.getTitle.should != "page_for_formatter_test_dont_match" | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# next cmd is an valid example where the the value param is supposed to be empty | |
# verifyNotValue | name=etext | | |
begin | |
@driver.find_element(:name, "etext").attribute(:value).should == "" | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotVisible | id=text2 | | |
begin | |
@driver.find_element(:id, "text2").should_not be_displayed | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotXpathCount | //input | 9 | |
begin | |
@driver.find_elements(:xpath, "//input").size.should != 9 | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyText | css=#text_tests | regexp:Text1 | |
# *This is a test of the open command. | |
begin | |
@driver.find_element(:css, "#text_tests").text.should =~ /Text1 | |
*This is a test of the open command./ | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyValue | name=etext | test msg | |
begin | |
@driver.find_element(:name, "etext").attribute(:value).should == "test msg" | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyVisible | name=dtext | | |
begin | |
@driver.find_element(:name, "dtext")should be_displayed | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyXpathCount | //input | 10 | |
begin | |
@driver.find_elements(:xpath, "//input").size.should == 10 | |
rescue ExpectationNotMetError => ex | |
@verification_errors << ex | |
end | |
# verifyNotSomethingSelected | name=num2 | | |
# ERROR: Caught exception [ERROR: Unsupported command [isSomethingSelected]] | |
# verifyTable | css=#table1.2.1 | r2d2 | |
# ERROR: Caught exception [ERROR: Unsupported command [getTable]] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment