woocheol
woocheol

Reputation: 97

Can't get element by css selector in Selenium

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))

Upvotes: 0

Views: 660

Answers (1)

Andersson
Andersson

Reputation: 52665

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")

Upvotes: 3

Related Questions