我想点击模态弹出窗口中的一个元素
This SO answer帮助我寻找合适的元素,但似乎选择了其他div(并实际点击了)。
弹出代码是:
<div id="reports-loader" class="modal" tabindex="-1" style="">
<div class="modal-header">
<h3 class="modal-title">Super Title</h3>
</div>
<div class="modal-body">
<iframe src="//some_source" width="640" height="360" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="">
</iframe>
<div id="reports-loader-skip-intro">
<a href="#" data-dismiss="modal" class="btn btn-large welcome-button skip gray" style="display: inline-block; width: 33%">Skip</a>
<a href="#" data-dismiss="modal" class="btn btn-large welcome-button skip try-now-redirect" style="display: inline-block; width: 66%">Try Feature</a>
</div>
</div>
</div>
<div id="reports-backdrop"></div>
"reports-backdrop"
div将成为覆盖整个浏览器窗口的灰色区域,位于弹出窗口("reports-loader"
)下方。
我用来获取 Skip 链接的代码是:
popup = @browser.div(:id => 'reports-loader', :class => 'modal')
puts popup.div(:class => 'modal-body').a(:text => 'Skip').exists?
popup.div(:class => 'modal-body').a(:text => 'Skip').click
和puts
返回 true
遗憾的是,未点击所需元素,但使用了"reports-backrop"
div:
true # <-- the puts printout
Selenium::WebDriver::Error::UnknownError: unknown error: Element is not clickable at point (101, 115). Other element would receive the click: <div id="reports-backdrop" style="opacity: 0.7141267829936161;"></div>
(Session info: chrome=35.0.1916.153)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
(eval):1:in `process_watir_call'
在整个情况下什么都可以 - 实际上点击了按钮,因为弹出消失(没有点击它停留在屏幕上)。不幸的是,由于错误,测试失败了 有没有人有一些线索......?