我想我几乎尝试了底部元素中的每一个xPath来使用xPath方法下载Excel文件,但不知道为什么它们是不正确的。此外,我还尝试了单击()
和键。输入
。任何帮助将非常感谢!如果你需要更多的细节,请告诉我。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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.support.ui import Select
import time
driver = webdriver.Chrome(r"C:\My\Path\chromedriver")
driver.get('https://reo-central.com/Default.aspx')
elem = driver.find_element_by_name('ctl00$LoginControl$LoginControl$UserName')
elem.clear()
elem.send_keys('MyAccount')
password = driver.find_element_by_name('ctl00$LoginControl$LoginControl$Password')
password.clear()
password.send_keys('MyPassword')
elem.send_keys(Keys.ENTER)
select=Select(driver.find_element_by_id('ddlResponsibleParty'))
select.select_by_value('344860')
Upcoming_Tasks = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, 'WebPagexPath'))
)
print(Upcoming_Tasks.text)
Upcoming_Tasks.click()
Upcoming_Tasks.send_keys(Keys.ENTER)
<li class="rtbItem rtbBtn">
xPath:
//*[@id="ctl00_MainContent_ctl00_OverdueItemsGrid_ctl00_ctl02_ctl00_GridToolbar"]/div/div/div/ul/li[3]
钥匙。输入:WebDriverExcture:消息:未知错误:无法聚焦元素
单击():WebDriverExcture:消息:未知错误:元素...在点(244,149)不可单击。其他元素将收到单击:...
<a class="rtbWrap" href="#">
xPath:
//*[@id="ctl00_MainContent_ctl00_OverdueItemsGrid_ctl00_ctl02_ctl00_GridToolbar"]/div/div/div/ul/li[3]/a
钥匙。进入:什么也没发生
*
*单击():**WebDriverException:消息:未知错误:元素。。。在点(244149)处不可单击。其他元素将收到单击:。。。
<span class="rtbIn">
xPath:
//*[@id="ctl00_MainContent_ctl00_OverdueItemsGrid_ctl00_ctl02_ctl00_GridToolbar"]/div/div/div/ul/li[3]/a/span/span/span
钥匙。输入:WebDriverExcture:消息:未知错误:无法聚焦元素
单击():WebDriverException:消息:未知错误:元素。。。在点(243147)处不可单击。其他元素将收到单击:。。。
<img alt="" src="../images/icons/document-excel.png" class="rtbIcon">
xPath:
//*[@id="ctl00_MainContent_ctl00_OverdueItemsGrid_ctl00_ctl02_ctl00_GridToolbar"]/div/div/div/ul/li[3]/a/span/span/span/img
钥匙。输入:WebDriverExcture:消息:未知错误:无法聚焦元素
单击():WebDriverExcture:消息:未知错误:元素在点(203,150)不可单击
<span class="rtbText">Export to Excel</span>
xPath:
//*[@id="ctl00_MainContent_ctl00_OverdueItemsGrid_ctl00_ctl02_ctl00_GridToolbar"]/div/div/div/ul/li[3]/a/span/span/span/span
钥匙。输入:WebDriverExcture:消息:未知错误:无法聚焦元素
单击():WebDriverException:消息:未知错误:元素。。。在点(254150)处不可单击。
用action类替换click事件,这将解决此异常
from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(driver)
actions.move_to_element(firstContest).click().perform()