user13411566
user13411566

Reputation:

How to search for multiple attributes selenium

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

Answers (2)

undetected Selenium
undetected Selenium

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

References

You can find a couple of relevant detailed discussions in:

Upvotes: 1

DonnyFlaw
DonnyFlaw

Reputation: 690

Try to use this XPATH

'//button[@type="submit" and @class="car"]'

Upvotes: 0

Related Questions