本文介绍了硒无法单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
网站检查元素的图片深度图片中的更多内容我的代码段
from selenium import webdriver from selenium.webdrivermon.keys import Keys import time from selenium.webdrivermon.action_chains import ActionChains from selenium.webdrivermon.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from time import sleep import requests /// excel = driver.find_element_by_name('Excel') excel.click()当我尝试运行它时,我得到了它,任何帮助将不胜感激
I then get this when I try to run it, any help would be appreciated
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="Excel"]"} 推荐答案所需的元素是 Angular 元素,因此要点击该元素,您必须为 WebDriverWait code> element_to_be_clickable(),您可以使用以下任一定位器策略:
The desired element is a Angular element, so to click on the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:
-
使用 CSS_SELECTOR :
使用 XPATH :
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@mat-button]/span[@class='mat-button-wrapper']//span[text()='Excel']"))).click()注意:您必须添加以下导入:
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdrivermon.by import By from selenium.webdriver.support import expected_conditions as EC更多推荐
硒无法单击按钮
发布评论