Reputation:
HTML:
<button type = "submit" class = "car">
How should I search for this button in selenium python using both the attributes type and class in find_element_by_xpath()
Upvotes: 0
Views: 3448
Reputation: 193108
To locate the element using both the attributes class
and type
you can club up them in a single locator and you can use either of the following Locator Strategies:
Using css_selector
:
element = driver.find_element_by_css_selector("button.car[type='submit']")
Using xpath
:
element = driver.find_element_by_xpath("//button[@class='car' and @type='submit']")
You can find a couple of relevant detailed discussions in:
Upvotes: 1
Reputation: 690
Try to use this XPATH
'//button[@type="submit" and @class="car"]'
Upvotes: 0