Rails 水豚硒元素不可点击,因为另一个元素遮盖了它

发布于 2025-01-15 06:44:38 字数 1088 浏览 2 评论 0原文

我正在努力寻找正确的语法来使用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 技术交流群。

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

发布评论

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

评论(1

感情旳空白 2025-01-22 06:44:38

查看您的 HTML,带有文本“September”的元素的 value 属性是“9”,因此正确的 CSS 应该是 option[value='9'],但是您确实应该使用选择。您收到未定义的局部变量变量错误,因为您需要将字符串传递给from,否则Ruby会将其解释为您试图调用一个不是的方法定义的

select 'September', from: 'select_test'

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 using select in this case. You're getting the undefined local variable variable error because you need to pass a string to from rather, otherwise ruby interprets it as you trying to call a method which isn't defined

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