如何选中此复选框 (capybara/ruby)
How tho check this checkbox (capybara/ruby)
如何勾选这个复选框?enter image description here
我试过了:
within('div[id="modalPersistEtapa"]') do
element = @driver.find_element(:xpath, '//*[@id="2018_4"]/i')
@driver.execute_script("arguments[0].click();"
没有成功! =(
我收到这个错误:
element click intercepted: Element <i class="i i-logout"></i> is not clickable at point (1878, 56). Other element would receive the click: <div class="modal fade bs-example-modal-lg in" id="modalPersistEtapa" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false" style="display: block;">...</div>
(Session info: chrome=87.0.4280.88) (Selenium::WebDriver::Error::ElementClickInterceptedError)
Backtrace:
Ordinal0 [0x012DC0C3+3326147]
...
不要使用直接驱动程序调用或 execute_script 尝试点击东西 - 如果你必须这样做,那你就做错了。
within('div[id="modalPersistEtapa"]') do
find(:xpath, './/*[@id="2018_4"]/i').click();
...
end
一般来说,对于这样的事情,我还建议使用 CSS 而不是 XPath,但 XPath 在这里可能有意义,因为您必须转义以 CSS 中的数字开头的 ID。另请注意 XPath 前面的“.//” - 没有点会使 within
毫无意义,因为 XPath 将转义范围。
如果这对你不起作用,那么尝试通过其他方式来做只会让你的测试变得毫无价值。
如何勾选这个复选框?enter image description here
我试过了:
within('div[id="modalPersistEtapa"]') do
element = @driver.find_element(:xpath, '//*[@id="2018_4"]/i')
@driver.execute_script("arguments[0].click();"
没有成功! =(
我收到这个错误:
element click intercepted: Element <i class="i i-logout"></i> is not clickable at point (1878, 56). Other element would receive the click: <div class="modal fade bs-example-modal-lg in" id="modalPersistEtapa" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false" style="display: block;">...</div>
(Session info: chrome=87.0.4280.88) (Selenium::WebDriver::Error::ElementClickInterceptedError)
Backtrace:
Ordinal0 [0x012DC0C3+3326147]
...
不要使用直接驱动程序调用或 execute_script 尝试点击东西 - 如果你必须这样做,那你就做错了。
within('div[id="modalPersistEtapa"]') do
find(:xpath, './/*[@id="2018_4"]/i').click();
...
end
一般来说,对于这样的事情,我还建议使用 CSS 而不是 XPath,但 XPath 在这里可能有意义,因为您必须转义以 CSS 中的数字开头的 ID。另请注意 XPath 前面的“.//” - 没有点会使 within
毫无意义,因为 XPath 将转义范围。
如果这对你不起作用,那么尝试通过其他方式来做只会让你的测试变得毫无价值。