1
votes

I am a beginner in web scraping in selenium python. I am trying to scrape the data that shows the annual prices for the various drugs. However I am getting an error that says :

Traceback (most recent call last): File "other.py", line 11, in paths = WebDriverWait(d,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, ".highcharts-grid highcharts-yaxis-grid path"))) File "wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

I am unsure what I have to do. The code I have so far is :

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)
1
Please add the full Traceback error to your question. - amanb
What are the Manual Steps which you are trying to Automate? - DebanjanB
I am trying to extract the annual prices for each of the drugs at the top of the page. The price only appears when you hover over each of the separated rectangles - Eric Oh
Does this or this discussion helps you? - DebanjanB
No not really. I have no clue what my error is so - Eric Oh

1 Answers

0
votes

If i search id as "highcharts-grid highcharts-yaxis-grid" in resources its saying 2 results found and if i search id "highcharts-grid highcharts-yaxis-grid path" its says me 0 match found i have share the screen shot please look into it and let us know

First Image using "highcharts-grid highcharts-yaxis-grid" enter image description here

Second Image using "highcharts-grid highcharts-yaxis-grid path"

enter image description here

UPDATE

Please visit this link if you want to learn how to find and use xpath :

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