【发布时间】:2022-01-15 05:04:20
【问题描述】:
我正在尝试发送一个值并单击按钮以检索某些 pdf,但我收到一个错误,即元素不可交互。我尝试使用不同的选择器,但我得到了同样的错误。 以下是我的代码:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
options=Options()
prefs = {"download.default_directory" : "D:\Trvael_Test_Script\GSTInvoiceDownloads"}
options.add_experimental_option("prefs",prefs)
from selenium.webdriver.chrome.service import Service
s=Service('C:/webdrivers/chromedriver.exe')
driver = webdriver.Chrome(service=s,options=options)
driver.get("link")
time.sleep(10)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="GST"]/span[1]'))).click()
time.sleep(5)
driver.switch_to.frame(driver.find_element(By.ID,'ifgstdownloadnFrame'))
time.sleep(5)
driver.find_element(By.XPATH,'//*[@id="txtpnr"]').send_keys('pnr')
driver.find_element(By.XPATH,'//*[@id="btnSubmit"]').click()```
Can anyone please let me know how to make the element interactable?
【问题讨论】:
标签: python selenium selenium-webdriver automation