无法在硒中找到 python {"method":"css selector","selector":"[id="downloadButton"]"}(会话信息:chrome =98.0.4758.102)
unable to loacate in selelium python {"method":"css selector","selector":"[id="downloadButton"]"} (Session info: chrome=98.0.4758.102)
这是我的代码,它只打开 chrome.Does 而不是点击我的按钮 ID gave.CAn 请任何人帮助我。
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
os.environ['PATH'] += r"C:/SeleniumDriver"
driver = webdriver.Chrome()
WebDriverWait(driver, 10)
driver.get("https://jqueryui.com/progressbar/#download")
my_element = driver.find_element(By.ID, 'downloadButton')
my_element.click()
按钮位于 iframe
内部,在这种情况下,您必须先切换到 iframe
,然后访问其中的元素。
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe")))
driver.find_element(By.ID, "downloadButton").click()
进口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
这是我的代码,它只打开 chrome.Does 而不是点击我的按钮 ID gave.CAn 请任何人帮助我。
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
os.environ['PATH'] += r"C:/SeleniumDriver"
driver = webdriver.Chrome()
WebDriverWait(driver, 10)
driver.get("https://jqueryui.com/progressbar/#download")
my_element = driver.find_element(By.ID, 'downloadButton')
my_element.click()
按钮位于 iframe
内部,在这种情况下,您必须先切换到 iframe
,然后访问其中的元素。
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe")))
driver.find_element(By.ID, "downloadButton").click()
进口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC