How can I get selenium/cucumber to interact with a "hidden" link that is now in a lightbox/colorbox?
I'm using the colorbox library to display lightboxes within my application (http://colorpowered.com/colorbox/). The code seems to work fine in the browser, but I'm having trouble getting the automated test to work.
Here is some inline HTML that gets generated:
<div class='hidden'>
<div id='override'>
Are you sure you want to override this action?
<br>
<a href="" class="close_colorbox">Cancel</a></li>
<a href="#" onclick="override(this); return false;">Override once</a>
</div>
</div>
This is the javascript that opens the colorbox:
$.fn.colorbox({innerWidth:600, inline:true, href:'#override', scrolling:false});
That code opens the lightbox and display the contents of my '#override' div. In my cucumber tests I can find text from inside that div, but I get an error if I try to follow a link:
When I follow "link that generates override"
Then I should see "Are you sure you want to override this action?" within "#cboxContent"
Then I should see "Cancel" within "#cboxContent"
# Then show me the page
When I follow "Cancel" within "#cboxContent"
Gives this error:
开发者_JAVA技巧Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotDisplayedError)
[remote server] resource://fxdriver/modules/atoms.js:7903:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:249:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:298:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:313:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/fxdriver@googlecode.com/components/nsCommandProcessor.js:190:in `'
./features/step_definitions/web_steps.rb:35
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:34:in `/^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/'
features/prerequisites.feature:38:in `When I follow "Cancel" within "#cboxContent"'
Has anyone seen this error before and how did you get around it? (If I uncomment the 'show me the page' step then it also works)
I am having a similar issue with the Jquery-mobile framework.
From what I understand, Capybara is supposed to wait until all the AJAX calls are completed before doing a check or moving on. However, if you are having an issue where you think the page isn't finished loading you could try adding a simple "sleep 1" to Capybara's stock "I press" step to see if that helps.
精彩评论