Rails 水豚硒元素不可点击,因为另一个元素遮盖了它
我正在努力寻找正确的语法来使用rails/capybara/selenium 在下拉列表中选择一个选项以进行测试。 HTML 页面的检查输出
<select id=”select_test” name=”select_test”>
<option value =””>Month</option>
<option value =”1”>January</option>
<option value =”9”>September</option>
</select>
<button type="button" data-toggle="dropdown" data—id="select_test" title="Month">
<div class="filter-option">
<div class="filter-option-inner">
<div class="filter-option-inner-inner">Month
</div>
</div>
</div>
</button>
以下是我尝试过两种方法的
:方法 1:
find(‘[title=Month]’).click
find("[value='9']").click
方法 2:
Select 'September', from: select_test, visible: :all
两种方法都会给我带来错误
Element <select id='select_test' class="" name=select_test"> is not clickable at point (189,175) because anohter element <div class="filter-option-inner-inner">obscures it
任何人以前都见过这个,可以帮助我找到正确的语法吗?
非常感谢。
I am a struggling to find the right syntax to select an option in a dropdown list using rails/capybara/selenium for testing purpose. Here are the inspect output of the HTML page
<select id=”select_test” name=”select_test”>
<option value =””>Month</option>
<option value =”1”>January</option>
<option value =”9”>September</option>
</select>
<button type="button" data-toggle="dropdown" data—id="select_test" title="Month">
<div class="filter-option">
<div class="filter-option-inner">
<div class="filter-option-inner-inner">Month
</div>
</div>
</div>
</button>
I have tried two approaches:
Approach 1:
find(‘[title=Month]’).click
find("[value='9']").click
Approach 2:
Select 'September', from: select_test, visible: :all
Both approach gives me the error
Element <select id='select_test' class="" name=select_test"> is not clickable at point (189,175) because anohter element <div class="filter-option-inner-inner">obscures it
Anyone would have seen this before and coul help me find the right syntax?
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看您的 HTML,带有文本“September”的元素的 value 属性是“9”,因此正确的 CSS 应该是
option[value='9']
,但是您确实应该使用选择。您收到
未定义的局部变量变量
错误,因为您需要将字符串传递给from
,否则Ruby会将其解释为您试图调用一个不是的方法定义的Looking at your HTML the value attribute of the element with text "September" is "9" so the correct CSS would have been
option[value=’9’]
, however you really should be usingselect
in this case. You're getting theundefined local variable variable
error because you need to pass a string tofrom
rather, otherwise ruby interprets it as you trying to call a method which isn't defined