element = WebDriverWait(driver, 50).until(EC.presence_of_element_located((By.XPATH,"//*[@id='button-1023-btnEl']")))
使用此代码,我得到错误,如下所示:
var.click()
File "C:\Users\ankij\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\ankij\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\ankij\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "C:\Users\ankij\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <span id="button-1023-btnEl" data-ref="btnEl" role="presentation" unselectable="on" style="height:auto;" class="x-btn-button x-btn-button-login-large x-btn-text x-btn-button-center ">...</span> is not clickable at point (1660, 590). Other element would receive the click: <div class="x-component x-border-box x-mask x-component-default x-focus x-component-focus x-component-default-focus" role="status" id="loadmask-1024" tabindex="0" componentid="loadmask-1024" style="width: 1920px; height: 930px; right: auto; left: 0px; top: 0px;">...</div>
答案 0 :(得分:0)
尝试替换:
element = WebDriverWait(driver, 50).until(EC.presence_of_element_located((By.XPATH,"//*[@id='button-1023-btnEl']")))
具有:
element = WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.ID,"button-1023-btnEl")))
答案 1 :(得分:0)
您需要使用 xpath 进行细化,如下所示:
element = WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH,"//span[@class='x-btn-button x-btn-button-login-large x-btn-text x-btn-button-center' and @id='button-1023-btnEl']")))
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC