0

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

1

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Try to use this XPATH

'//button[@type="submit" and @class="car"]'
DonnyFlaw
  • 581
  • 3
  • 9