Selenium Webdriver stuck when find_element method called with a non-existed widget

前端 未结 2 562
醉梦人生
醉梦人生 2020-12-21 18:53

I\'m trying to test with selenium webdriver. My version of selenium is 2.33 and the browser is Firefox. The scripting language is python

Now when I call the method <

2条回答
  •  执笔经年
    2020-12-21 19:21

    find_element_* raises selenium.common.exceptions.NoSuchElementException if element is not found.

    find_elements_* return empty list if element is not found.

    Both functions does not stuck.

    According to Selenium documentation:

    4.1. Locating by Id

    Use this when you know id attribute of an element. With this strategy, the first element with the id attribute value matching the location will be returned. If no element has a matching id attribute, a NoSuchElementException will be raised.

    ...

    4.2. Locating by Name

    Use this when you know name attribute of an element. With this strategy, the first element with the name attribute value matching the location will be returned. If no element has a matching name attribute, a NoSuchElementException will be raised.

提交回复
热议问题