2

I am attempting to download a csv file, which is available by clicking the button entitled 'Export Data' on this webpage. Given that the button runs a javascript procedure, I am trying to utilise selenium for this. My current attempt below generates the error message:

"WebDriverException: unknown error: missing or invalid 'entry.level' (Session info: chrome=63.0.3239.132) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.16299 x86_64)"

chrome_path = path
driver=webdriver.Chrome(chrome_path)
url = 'http://www.fangraphs.com/projections.aspx?pos=all&stats=bat&type=fangraphsdc&team=0&lg=all&players=0&sort=24%2cd'
driver.get(url)
driver.find_element_by_xpath('//*[@id="ProjectionBoard1_cmdCSV"]').click()

The error occurs on the final line of code. Any ideas?

1 Answer 1

2

As per the URL you have shared the WebElement with text as Export Data is within a <a> tag. Hence you would be able to click the link with the following line of code :

driver.find_element_by_link_text("Export Data").click()

But this solution mat still fail as your main issue is the version compatibility among the binaries you are using as follows :

  • You are using chromedriver=2.27.440174
  • Release Notes of chromedriver=2.27.440174 clearly mentions the following :

Supports Chrome v55-57

  • You are using chrome=63.0.3239.132
  • Release Notes of chromedriver=2.34 clearly mentions the following :

Supports Chrome v61-63

  • Your Selenium Version Info is unknown to us.
  • Your java.version is unknown to us.

Solution

  • Upgrade JDK to recent levels JDK Version 8 Update 151.
  • Keep ChromeDriver to ChromeDriver v2.34 level.
  • Keep Chrome to Chrome v63.x level.
  • Upgrade Selenium to current levels Version 3.8.1.
  • Execute your Test.
Sign up to request clarification or add additional context in comments.

4 Comments

Following your provided solution the scraper can click on that very link @DebanjanB. However, the file gets downloaded programmatically is not the one available there in that webpage. The file the scraper downloads has an extension like .tmp. Manual click can let the browser download the exact file, though. Do you have any idea why this different behavior? +1 for your current solution.
Thank you - after updating selenium and chromedriver and using link_text to find the element to click, the code does download the file in chrome. I was curious whether i can open the csv directly in python (as opposed to opening the file from the download directly after download is complete).
@user3725021 Shouldn't that be a separate question :) Please Accept the Answer.
Perhaps it should. I generally try and avoid asking two questions to solve one problem, but given i didn't describe the full problem above, i've added a second question here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.