我怎样才能让硒/黄瓜与“隐藏”的交互?现在位于灯箱/彩盒中的链接?

发布于 2024-11-09 18:24:49 字数 2883 浏览 1 评论 0原文

我正在使用 colorbox 库在我的应用程序中显示灯箱 (http://colorpowered.com/colorbox/)。该代码似乎在浏览器中运行良好,但我无法让自动化测试正常工作。

下面是生成的一些内联 HTML:

<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>

这是打开 colorbox 的 javascript:

$.fn.colorbox({innerWidth:600, inline:true, href:'#override', scrolling:false});

该代码打开 lightbox 并显示我的“#override”div 的内容。在我的黄瓜测试中,我可以从该 div 内部找到文本,但如果我尝试点击链接,则会收到错误:

  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"

给出此错误:

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/[email protected]/components/nsCommandProcessor.js:249:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/[email protected]/components/nsCommandProcessor.js:298:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/[email protected]/components/nsCommandProcessor.js:313:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/[email protected]/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"'

之前有人见过此错误吗?您是如何解决它的? (如果我取消注释“显示页面”步骤,那么它也有效)

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:

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/[email protected]/components/nsCommandProcessor.js:249:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/[email protected]/components/nsCommandProcessor.js:298:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/[email protected]/components/nsCommandProcessor.js:313:in `'
[remote server] file:///var/folders/nn/nn5oYAICGPawlH+1W406+k+++TI/-Tmp-/webdriver-profile20110524-2973-1d5qq7w/extensions/[email protected]/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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾冷 2024-11-16 18:24:49

我在 Jquery-mobile 框架上遇到了类似的问题。

据我了解,Capybara 应该等到所有 AJAX 调用完成后再进行检查或继续。但是,如果您遇到页面未完成加载的问题,您可以尝试在 Capybara 的“我按”步骤中添加一个简单的“睡眠 1”,看看是否有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文