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

前端 未结 6 958
甜味超标
甜味超标 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:37

    Add explicitly wait

    from selenium.webdriver.support import expected_conditions as EC
    
    userNameElement= WebDriverWait(driver, 2).until(
    EC.presence_of_element_located((By.NAME, "id"))
    userNameElement.send_keys('abc')
    
    pwdElement= WebDriverWait(driver, 2).until(
    EC.presence_of_element_located((By.NAME, "pwd"))
    pwdElement.send_keys('cdef')
    

    Here, I am expecting that your locators are correct.

提交回复
热议问题