How to check this checkbox?enter image description here
I tried:
within('div[id="modalPersistEtapa"]') do element = @driver.find_element(:xpath, '//*[@id="2018_4"]/i') @driver.execute_script("arguments[0].click();"
No success! =(
I got this error:
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]
…
Advertisement
Answer
Don’t use direct driver calls or execute_script to try and click on things – if you’re having to do that you’re doing something wrong.
within('div[id="modalPersistEtapa"]') do find(:xpath, './/*[@id="2018_4"]/i').click(); ... end
Generally for things like this I’d also recommend using CSS rather than XPath but XPath may make sense here since you’d have to escape an id starting with a number in CSS. Also note the “.//” in front of the XPath – without the dot it makes the within
pointless since the XPath will escape scope.
If that doesn’t work for you then trying to do it via other means is just making your tests worthless.