Unable to locate using find element by link

南笙酒味 提交于 2019-12-25 02:22:55

问题


Newbie in testing. I generated a test case using Selenium, and then exported it as a Python script. Now, when I try to run that in terminal, I get following error:

raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: u'Unable to locate element: {"method":"link                                                                                               
text","selector":"delete"}' 

I am using the command generated by Selenium i.e

driver.find_element_by_link_text("delete").click()

The reason for the error I believe is that the link "delete" in my web page is seen only when I click on a particular line to be deleted. So I guess it is being unable to locate the link. Please suggest what alternative measure could I use to locate and click on the "delete" link. Thanks in Advance:)


回答1:


This may occur when selenium is trying to find the link while your application hasn't rendered it yet. So you need to make it wait until the link appears:

browser.implicitly_wait(10)

The answer which helped me is here.



来源:https://stackoverflow.com/questions/10831207/unable-to-locate-using-find-element-by-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!