Get all Elements in a Form

后端 未结 4 1318
渐次进展
渐次进展 2021-02-02 14:56

I would like to use Selenium to submit a form which contains several elements. For example:

4条回答
  •  余生分开走
    2021-02-02 15:34

    driver = webdriver.Firefox()
    driver.get("https://www.hackerearth.com/problems/")
    
    #find all form input fields via form name
    _inputs = driver.find_elements_by_xpath('//form[@name="signup-form"]//input')
    
    for input in _inputs:                                                             
        #print attribute name of each input element 
        print input.get_attribute('name')
    

    o/p
    first_name
    last_name
    email
    password
    submit

提交回复
热议问题