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
  • 151,581
  • 34
  • 225
  • 281

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
  • 151,581
  • 34
  • 225
  • 281
0

Try to use this XPATH

'//button[@type="submit" and @class="car"]'
DonnyFlaw
  • 412
  • 1
  • 8