Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Selenium click on <div class="foo'>

I try to use Selenium click() method:

elem = driver.find_element_by_class('foo').click()

on html tag:

<div class="foo"></div>

Is it possible?

like image 234
J Mascis Avatar asked Jul 18 '26 05:07

J Mascis


1 Answers

You should use

elem = driver.find_element_by_class_name('foo').click()

or

elem = driver.find_element_by_xpath('//div[@class="foo"]').click()
like image 129
Andersson Avatar answered Jul 20 '26 19:07

Andersson