我正在尝试点击此元素, 但出现
之类的错误>> ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (271, 705)
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@action="/battle/"]/div/input[2]')))
element.click();
这也没有帮助获得超时异常。我认为元素有点覆盖
具有:
[driver.find_element_by_xpath('//[@action="/battle/"]/div/input[2]').click()]
<form action="/battle/" method="post" name="4416" id="4416" onsubmit="get('/battle/', '', this); disableSubmitButton(this); return false;"><div class="battleView" style="float:left; width:65%;"><h3 class="heading-maroon no-right-border-rad margin-right-2">Attack Results</h3><table cellpadding="0" cellspacing="0" style="width: 80%; text-align: center; margin: 0 auto;">
...
</tbody></table><input type="hidden" class="button-maroon button-small" name="action" value="attack">
<input type="submit" class="button-maroon button-small" value=" Attack .. "></div>
</form>
答案 0 :(得分:0)
似乎在错误消息中显示了X / Y坐标(271,705)。我将尝试使用诸如AppRobotic之类的宏产品来查找您在XPATH中发现问题,移动鼠标或发送击键TABS并单击的元素的X / Y坐标。一个简单的例子:
import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")
from selenium import webdriver
# navigate to Yahoo
driver = webdriver.Firefox()
driver.get('https://www.yahoo.com')
# sleep 1 second
x.Wait(1000)
link = driver.find_element_by_link_text('Mail')
if len(link) > 0
link[0].click()
else
x.Wait(3000)
# use UI Item Explorer to get X,Y coordinates of Mail box
x.MoveCursor(271,705)
# click inside Search box
x.MouseLeftClick
# could also try tabbing over and pressing Enter
x.Type("{TAB}")
x.Type("{ENTER}")
另一个想法是尝试先使用Selenium滚动到该元素:
from selenium.webdriver.common.action_chains import ActionChains
element = driver.find_element_by_xpath('//[@action="/battle/"]/div/input[2]')
actionchains = ActionChains(driver)
actionchains.move_to_element(element).perform()