Cucumber + webrat + selenium, how to ignore hidden text?

I use Cucumber, webrat and selenium to test a web application. To check for changes, I use " to see" something . " However, in many places, the text to be checked changes only from hidden to visible (this can be caused by removing the" hidden "class from itself or from one of its ancestors). In this case, the 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 verify this?

Environment: cucumber 0.3.11, selenium client 1.2.17, webrat 0.6.0

Thanks.

+4
source share
3 answers

For such cases, I use these two user 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 

Place them in the Ruby file in the step_definitions / directory.

So, in your case, instead of Then I should see a "something" to use . Then the element corresponding to "something" should be visible .

+5
source

Is this used when using has_selector ("div # myId.hidden")?

+3
source

The accepted solution does not work with the following environment: Rails (3.0.0), webrat (0.7.3) selenium-client (1.2.18), cucumber (0.10.)

The solution that works, with the example provided in the answer now:

 Then /^the element matched by "([^\"]*)" should be visible$/ do |locator| selenium.is_visible(locator).should be_true end Then /^the element matched by "([^\"]*)" should not be visible$/ do |locator| selenium.is_visible(locator).should_not be_true end 
+1
source

All Articles