【发布时间】:2022-12-04 18:59:32
【问题描述】:
我知道已经上传了对同一个问题的回答,但我试过它们对我不起作用,因为 selenium 代码也有一些更新。收到此错误selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div class="up-typeahead-fake" data-test="up-c-typeahead-input-fake">...</div> is not clickable at point (838, 0). Other element would receive the click: <div class="up-modal-header">...</div> ,尝试在此输入中发送我的搜索关键字时标有“技能搜索”
预先搜索弹出窗体。
这是我的代码:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.proxy import Proxy, ProxyType
import time
from fake_useragent import UserAgent
import pyttsx3
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def main():
options = Options()
service = Service('F:\\work\\chromedriver_win32\\chromedriver.exe')
options.add_argument("start-maximized")
options.add_argument('--disable-blink-features=AutomationControlled') #Adding the argument
options.add_experimental_option("excludeSwitches",["enable-automation"])#Disable chrome contrlled message (Exclude the collection of enable-automation switches)
options.add_experimental_option('useAutomationExtension', False) #Turn-off useAutomationExtension
options.add_experimental_option('useAutomationExtension', False) #Turn-off useAutomationExtension
prefs = {"credentials_enable_service": False,
"profile.password_manager_enabled": False}
options.add_experimental_option("prefs", prefs)
ua = UserAgent()
userAgent = ua.random
options.add_argument(f'user-agent={userAgent}')
driver = webdriver.Chrome(service=service , options=options)
url = 'https://www.upwork.com/nx/jobs/search/?sort=recency'
driver.get(url)
time.sleep(7)
advsearch = driver.find_element(By.XPATH,'//button[contains(@title,"Advanced Search")]')
advsearch.click()
time.sleep(10)
skill = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,'//div[contains(@class,"up-typeahead")]')))
skill.click()
time.sleep(10)
keys = ["Web Scraping","Selenium WebDriver", "Data Scraping", "selenium", "Web Crawling", "Beautiful Soup", "Scrapy", "Data Extraction", "Automation"]
for i in range(len(keys)):
skill.send_keys(Keys[i],Keys.ENTER)
time.sleep (2)
main()
我尝试将键发送到输入字段,但它给我 Error .ElementClickInterceptedException ,我尝试从堆栈上一个与此错误相关的问题答案中获取旧答案,但它们对我不起作用,因为 selenium 代码也有一些更新。
【问题讨论】:
标签: python selenium selenium-webdriver xpath automation