Perl WWW::Selenium';找不到元素';
我在WWW::Selenium查找href时遇到问题 这是我正在寻找的HTML元素Perl WWW::Selenium';找不到元素';,perl,selenium,Perl,Selenium,我在WWW::Selenium查找href时遇到问题 这是我正在寻找的HTML元素 <a href="/auctions?organization_id=2">Sell Products</a> 以下是WWW::Selenium正在输出的错误 Error requesting http://localhost:4444/selenium-server/driver/: ERROR: Element //a[contains(@href, "/auctions?organ
<a href="/auctions?organization_id=2">Sell Products</a>
以下是WWW::Selenium正在输出的错误
Error requesting http://localhost:4444/selenium-server/driver/:
ERROR: Element //a[contains(@href, "/auctions?organization_id=2")] not found
任何提示/帮助都将不胜感激
编辑
添加周围的HTML以帮助进行故障排除
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children">
<a href="/auctions?organization_id=2">Sell Products</a>
</li>
</ul>
<ul class="sub-menu">
<li class="menu-item menu-item-type-custom menu-item-object-custom">
<a href="/dashboard?_tab=seller">Seller Dashboard</a>
</li>
</ul>
-
我建议使用等待元素出现,而不是使用硬编码的睡眠
my $locator = q{//a[contains(@href, "/auctions?organization_id=2")]};
$sel->wait_for_element_present($locator, $timeout)
$sel->click($locator);
不确定,但您可能必须退出\?
,而且,您可以尝试使用组织id=2
并查看它是否有效。谢谢,我尝试了两种方法:退出?还有就是organization_id=2,同样的问题。是否可以简单地使用xPath?好的,我使用的是firefox的xPath定位器,它说链接的xPath为id('menu-main-menu')/x:li[3]/x:a
,我将修改代码并发布结果。谢谢@rutter。我添加了Perl代码sleep5代码>在导致问题的元素和问题解决之前。执行测试时未加载页面,因此未找到错误。
my $locator = q{//a[contains(@href, "/auctions?organization_id=2")]};
$sel->wait_for_element_present($locator, $timeout)
$sel->click($locator);