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