0

I can't get element by css selector in Selenium using Python so I can't click download. This is my code what is this wrong?

link = u''

mydriver = webdriver.Firefox()

try:
    mydriver.get(link)
    btn = mydriver.find_element_by_css_selector("//a[class='button neutral']")
    print link

except Exception as e:
    print "link: {0}, exception: {1}".format(link, repr(e))

1 Answer 1

4

You use XPath but not a css-selector. Try

btn = mydriver.find_element_by_xpath("//a[@class='button neutral']")

If you want to use css-selector try

mydriver.find_element_by_css_selector("a.button.neutral")
Sign up to request clarification or add additional context in comments.

3 Comments

thanks. find_element_by_xpath it is working for me. but css_selector is not working for me.
if you want to use css-selector try mydriver.find_element_by_css_selector("a.button.neutral")
You should add your CSS selector comment to your answer. I think that's what OP is looking for.

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.