簡體   English   中英

引發TimeoutException(消息,屏幕,堆棧跟蹤)selenium.common.exceptions.TimeoutException:消息:使用Selenium Python

[英]raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: using Selenium Python

我是使用Selenium python進行網絡抓取的初學者。 我正在嘗試抓取各種葯物的年度價格數據。 但是我得到一個錯誤,說:

追溯(最近一次調用):文件“ other.py”,第11行,路徑= WebDriverWait(d,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,“ .highcharts-grid highcharts-yaxis-grid路徑“)))文件” wait.py“,第80行,直到引發TimeoutException(message,screen,stacktrace)selenium.common.exceptions.TimeoutException:消息:

我不確定該怎么做。 到目前為止,我的代碼是:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

url = 'http://abacus.realendpoints.com/ConsoleTemplate.aspx?act=qlrd&req=nav&mop=abacus!main&pk=ed5a81ad-9367-41c8-aa6b-18a08199ddcf&ab-eff=1000&ab-tox=0.1&ab-nov=1&ab-rare=1&ab-pop=1&ab-dev=1&ab-prog=1.0&ab-need=1&ab-time=1543102810'
d = webdriver.Chrome()
actions = ActionChains(d)
d.get(url)
paths = WebDriverWait(d,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, ".highcharts-grid highcharts-yaxis-grid path")))
results = []
for path in paths:
    actions.move_to_element(path).perform()
    actions.click_and_hold(path).perform()
    items = d.find_elements_by_css_selector('#priceChart path + text tspan')
    result = [item.text for item in items]
    if result:
        results.append(result)
d.close()
print(results)

如果我在資源中搜索id為"highcharts-grid highcharts-yaxis-grid" ,則找到說2結果,如果我搜索id "highcharts-grid highcharts-yaxis-grid path"說我找到0個匹配項,我分享了屏幕截圖請調查一下,讓我們知道

使用“ highcharts-grid highcharts-yaxis-grid”的第一張圖片 在此處輸入圖片說明

使用“ highcharts-grid highcharts-yaxis-grid路徑”的第二張圖片

在此處輸入圖片說明

更新

如果您想學習如何查找和使用xpath,請訪問此鏈接:

https://confengine.com/selenium-conf-2018/proposal/6018/chropath-a-smarter-way-to-get-locators-and-verify-them

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM