我已經用 Python 和 Selenium 撰寫了一個“Lovoo”機器人,我快完成了。
現在我有以下問題:

當機器人點擊用戶時,會打開一個視窗。要退出此視窗,機器人必須在其外部單擊。
但是從那時起,所有源代碼都已更改,我無處可使用 xpath 或使用 selenium 單擊。我根本無法獲得任何有效的 xpath。
我試過
WebDriverWait(DRIVER,10).until(EC.element_to_be_clickable((By.XPATH,'//body[1]')))
DRIVER.find_element_by_xpath('//body[1]).click()
但點擊只是隨機作業,很少。
錯誤:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div class="thumbnail thumbnail-square u-margin-0">...</div> is not clickable at point (370, 497). Other element would receive the click: <div class="absolute-fill text-left" ng-transclude=""></div>
(Session info: chrome=96.0.4664.9)
我不想使用
action.click()
因為那樣我就不能用我的滑鼠做其他事情了。
uj5u.com熱心網友回復:
如果我清楚地理解它,那么您正在嘗試click使用co-ordinate而不是web element.
如果是這種情況,那么您可以定義如下所示的偏移量并嘗試單擊它。
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).move_by_offset(10,10).click().perform()
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/329944.html
