gpt4 book ai didi

python - "Element click intercepted"尝试单击复选框时出错

转载 作者:行者123 更新时间:2023-12-01 06:55:50 36 4
gpt4 key购买 nike

我想在加载页面后单击复选框,但收到以下错误消息:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <img class="checkboximage" src="/images/nav/ns_x.gif" alt=""> is not clickable at point (843, 7). Other element would receive the click: <a class="ns-help" onclick="nlPopupHelp('EDIT_TRAN_CUSTINVC');" tabindex="0" onkeypress="(event.keyCode == 13 || event.charCode == 32) &amp;&amp; nlPopupHelp('EDIT_TRAN_CUSTINVC');">...</a>

这就是我现在所拥有的:在此之前我已经尝试过其他几种方法

collectionsbox = driver.find_element(By.CSS_SELECTOR,"#custbody_in_collections_fs_inp")
driver.execute_script("arguments[0].scrollIntoView(true)", collectionsbox)

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@id='custbody_in_collections_fs']//img[@class='checkboximage']"))).click()

collectionsbox.click() #USUALLY FAILS RIGHT HERE

savebutton = driver.find_element(By.XPATH,"//input[@id='btn_multibutton_submitter']")

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='btn_multibutton_submitter']"))).click()

driver.execute_script("arguments[0].scrollIntoView(true)", savebutton)
savebutton.click()
time.sleep(2)
driver.switch_to.alert.accept()

我尝试了EC方法,等了几秒钟,向下滚动查看元素。我什至使用过 Xpath、ID 和 CSS。

<input onclick="setEventCancelBubble(event); this.isvalid=(nlapiValidateField(null,'custbody_in_collections')); if (this.isvalid) {setWindowChanged(window, true);nlapiFieldChanged(null,'custbody_in_collections');;} else if ( window.loadcomplete &amp;&amp; !document.page_is_resetting ) {setFormValue(this, !this.checked);}" aria-labelledby="custbody_in_collections_fs_lbl" onchange="NLCheckboxOnChange(this); " onkeypress="NLCheckboxOnKeyPress(event);  return true;" name="custbody_in_collections" id="custbody_in_collections_fs_inp" type="checkbox" value="T" class="checkbox" style="">
<input type="hidden" name="custbody_in_collections_send" style="">
<img class="checkboximage" src="/images/nav/ns_x.gif" alt="" style="">

我所需要的只是单击复选框,然后单击“保存到顶部”。

最佳答案

似乎 DOM 上的另一个元素无意中隐藏了您尝试单击的元素。您可以尝试执行 Javascript 来进行点击。这通常可以解决我的问题。

您可以将 collectionsbox.click() #USUALLY FAILS RIGHT HERE 替换为:

driver.execute_script("arguments[0].click();", collectionsbox)

关于python - "Element click intercepted"尝试单击复选框时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58808856/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com