find submit button in selenium without id

前端 未结 3 1236
独厮守ぢ
独厮守ぢ 2020-12-31 05:46

I have a button


I cannot fin

相关标签:
3条回答
  • 2020-12-31 06:31

    You could try to find the element with an XPath expression or a CSS selector like input[type="button"], and then just click the element.

    0 讨论(0)
  • 2020-12-31 06:33

    There are many options here, to name a few:

    If class alone is unique, you can use

    driver.find_element_by_css_selector(".button_main").click()
    

    If class + value combo is unique, you can use:

    driver.find_element_by_css_selector(".button_main[value='something']").click()
    

    You can also use xpath:

    driver.find_element_by_xpath("//input[@type='submit' and @value='something']").click()
    

    If none of those work (i.e. they are not identifying button uniquely), look at the elements above the button (for example <form) and provide the xpath in format:

    driver.find_element_by_xpath("//unique_parent//input[@type="submit" and @value='something']").click()
    
    0 讨论(0)
  • 2020-12-31 06:37

    i recommend xpath chrome extension, with it you will be able to get the path by running the extension and shift-clicking on the element you want this chrome extension https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl

    0 讨论(0)
提交回复
热议问题