Не могу нажать элемент - PullRequest
0 голосов
/ 28 апреля 2019

Я пытаюсь щелкнуть по этому элементу, но получаю сообщение об ошибке, например

>> 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>

1 Ответ

0 голосов
/ 28 апреля 2019

Похоже, что он показывает координаты X / Y (271,705) в сообщении об ошибке. Я бы попробовал такой макропродукт, как AppRobotic, чтобы найти координаты X / Y элементов, которые у вас возникают при поиске в XPATH, перемещении мыши или отправке 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()
...