selenium in python : NoSuchElementException: Message: no such element: Unable to locate element

前端 未结 6 773
甜味超标
甜味超标 2020-11-22 08:41

I tried typing \'abc\' in the first block of id and \'cdef\' in the second block of password. However, the error code at the bottom comes up.

from selenium          


        
6条回答
  •  灰色年华
    2020-11-22 09:28

    The site you are trying to access does not have an element with a tag name id. Examine the site carefully.

    
    

    If the input has an id value, try this;

    driver.find_element_by_id("id")
    

    Example Use:

    HTML:

    Python:

    username = driver.find_element_by_name("username")
    password = driver.find_element_by_name("password")
    
    username.send_keys("your_username")
    password.send_keys("your_password")
    
    driver.find_element_by_id("btn-login").click()
    

提交回复
热议问题