SSerb1989
SSerb1989

Reputation: 89

Python Selenium dynamic link error message

I'm trying to download files from a work webpage (which is not public, unfortunately) and the download link is dynamic which changes for the file:

https://s3.amazonaws.com_______________________________

My code is:

driver.find_element_by_xpath("//a[contains(@href='https')]").click()

the Error is

SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//a[contains(@href='https')]' is not a valid XPath expression.

Any help on what I'm missing would be much appreciated, Thanks!

Upvotes: 0

Views: 63

Answers (2)

cruisepandey
cruisepandey

Reputation: 29362

The xpath is wrong.

Instead of

//a[contains(@href='https')]

it should be

//a[contains(@href,'https')]

While using contains, note that to use , not =

Upvotes: 1

Muhteva
Muhteva

Reputation: 2832

According to the error, what you tried is not a valid XPATH expression for Selenium. Try this one:

driver.find_element_by_xpath("//a[contains(@href, 'https')]").click()

Upvotes: 1

Related Questions