我正在开发一个不和谐的机器人,它使用selenium从instagram账户上抓取一个缩放链接。直到今天,当它开始给出错误selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate2020-06-02T03:45:55.540204+00:00 app[worker.1]: File "/app/.heroku/python/lib/py
如果我使用运行测试,则selenium测试将失败。如果我用python manage.py test ...运行它们,这个测试就会通过。我有一个测试套件,包括一些普通的python/django测试,以及一些使用Selenium的测试。CustomWebDriver()是selenium.webdriver.firefox.webdriver的子类。当我在覆盖范围内运行它时,test_instructions_logic测试会失败,因为它找不到"#some_element"。
我正在使用selenium来运行我创建的测试。现在我想开始错误处理。我希望能够获得找不到的元素,并在我的错误日志中显示类似于"Element start could not be found"的内容。目前,我只是将每个测试包装在一个try catch中,然后说Couldn't find element,然而,这是非常广泛的,并且不会缩小它找不到的元素的范围。
当我的代码运行并且元素存在时,它的eleExists被设置为true,但是当它不存在而不是被设置为false时,我得到一个NoSuchElementException。我想知道这是不是Selenium中的一个bug?// do other stuff System.out.println(e);我明白了这个问题: Selenium