无法单击元素

问题描述 投票:0回答:1

我试图点击这个元素,但得到错误

>> 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>
python selenium click element interrupted-exception
1个回答
0
投票

它看起来像是在错误消息中显示X / Y坐标(271,705)。我尝试使用像AppRobotic这样的宏产品来查找使用XPATH找到问题的元素的X / Y坐标,移动鼠标或发送击键TABS,然后单击它。一个简单的例子:

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()
© www.soinside.com 2019 - 2024. All rights reserved.