So I always written scripts using perl
but making an attempt with Ruby, so this question may sound real silly but ill make a go.
I am writing Selenium Webdriver scripts in ruby Test::Unit
Below is some sample code.
def test_runit
@driver.get(@base_url + "/")
@driver.find_element(:id, "gbqfq").clear
@driver.find_element(:id, "gbqfq").send_keys "selenium"
@driver.find_element(:id, "gbqfb").click
@driver.find_element(:link, "Selenium - Web Browser Automation").click
assert(@driver.find_element(:tag_name => "body").text.include?("administration tasks"),"the assert works")
@driver.find_element(:link, "Support").click
end
With an output
ruby runit.rb
Loaded suite runit
Started
.
Finished in 9.732149 seconds.
1 tests, 2 assertions, 0 failures, 0 errors
While testing I need to check if text is present on the page.
Using assert works just fine.
But if it fails the test ends there and there and does not proceed any further.
In perl I could you some thing like verify which basically marks something as failed and proceed ahead.
I am hoping to get a result like this
ruby runit.rb
Loaded suite runit
Started
.
Finished in 9.732149 seconds.
1 tests, 1 assertion, 1 failure, 0 errors
But verify does not work for ruby test Unit or may be i am doing it wrong.
Can some one point me to some sample code?
thanks
Got it!!
One would need to use rescue.
thanks for responding back.