Selenium Dynamic Element Python

前端 未结 3 1598
北恋
北恋 2021-01-29 00:12

Hello I am using selenium. I have to send key to this input.

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 01:08

    You Can Locate element using xpath kr css where id or classname is not unique.

    driver.find_element_by_xpath("//input[@name='emailAddress']")
    

    Or

    driver.find_element_by_name('emailAddress')
    

    Or

    driver.find_element_by_css_selector("input[name='emailAddress']")
    

    Note: you can do chaining aswell if combination of attributes are unique:

    driver.find_element_by_xpath("//input[@name='emailAddress'][@type='email']")
    

提交回复
热议问题