无法通过链接使用查找元素定位 [英] Unable to locate using find element by link

查看:40
本文介绍了无法通过链接使用查找元素定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

测试新手.我使用 Selenium 生成了一个测试用例,然后将其导出为 Python 脚本.现在,当我尝试在终端中运行它时,出现以下错误:

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"}' 

我正在使用 Selenium 生成的命令,即

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:)

推荐答案

当 selenium 试图在您的应用程序尚未呈现链接时尝试查找链接时,可能会发生这种情况.所以你需要让它等到链接出现:

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)

帮助我的答案是这里.

这篇关于无法通过链接使用查找元素定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆