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

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

    No Such Element Exception usually comes when web driver can't see the element you are trying to perform an action on. Reason's can be:

    1. your ID or Name or Xpath or CssSelector can be wrong.

    2. Your element might be inside an an iframe so that web driver can't see or detect it. Switch to an iframe through Selenium and python

    3. Your element is taking time to appear on the UI, so you can use an explicit wait to solve this. https://selenium-python.readthedocs.io/waits.html

提交回复
热议问题