I am using Cucumber, webrat and selenium to test a web application. I use 'I should see "something"' to verify changes. However, in many places, text to be verified only changes from hidden to visible (this might be caused by removing 'hidden' class from itself or one of its ancestors). In this case, above test does not actually verify the change. I am trying to use 'response.should_not have_tag("div#myId.hidden")', which does not work. What is the recommended way to test this?
Environment: cucumber 0.3.11, selenium-client 1.2.17, webrat 0.6.0
Thank you.
For cases as these I use those two custom steps:
Then /^the element matched by "([^\"]*)" should be visible$/ do |locator|
selenium.should be_visible(locator)
end
Then /^the element matched by "([^\"]*)" should not be visible$/ do |locator|
selenium.should_not be_visible(locator)
end
Put those into a Ruby file under step_definitions/ directory.
So, in your case, instead of Then I should see "something" use Then the element matched by "something" should be visible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With