Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium::Remote::Driver:单击锚元素不起作用_Selenium - Fatal编程技术网

Selenium::Remote::Driver:单击锚元素不起作用

Selenium::Remote::Driver:单击锚元素不起作用,selenium,Selenium,我有下面的html代码,其中包含一个锚元素,我想单击它,以便调用该元素中指定的脚本 <div class="ToolsContainer"> <a target="_blank" href="checkup.aspx"> <img class="Tools-img" src="/images/tools02.jpg"> <p class="Tools-text center gray"><span class="black_bold Tool

我有下面的html代码,其中包含一个锚元素,我想单击它,以便调用该元素中指定的脚本

<div class="ToolsContainer">
<a target="_blank" href="checkup.aspx">
<img class="Tools-img" src="/images/tools02.jpg">
<p class="Tools-text center gray"><span class="black_bold Tool">Checkup</span>
<br>Tool area.</p></a>
</div>
但我得到了以下错误:

Error while executing command: click: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.: mouseClick
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'myhost.de', ip: '178.xxx.yyy.zzz', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-042stab127.2', java.version: '1.8.0_172'
Driver info: driver.version: unknown at /usr/local/share/perl/5.20.2/Selenium/Remote/Driver.pm line 313.
 at /usr/local/share/perl/5.20.2/Selenium/Remote/Driver.pm line 313.
Since a few links/buttons where accessible for JavaScriptcode in this project, I tried this as well:
$selen->execute_script( 'var xpath = "//a[@href=\'checkup.aspx\']"; var xpathResult = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; xpathResult.click()' );
这次错误消息如下所示:

Error while executing command: executeScript: TypeError: xpathResult is null
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'myhost.de', ip: '178.xxx.yyy.zzz', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-042stab127.2', java.version: '1.8.0_172'
Driver info: driver.version: unknown at /usr/local/share/perl/5.20.2/Selenium/Remote/Driver.pm line 313.
 at /usr/local/share/perl/5.20.2/Selenium/Remote/Driver.pm line 313.

这里出了什么问题?对代码的哪些更改(我被绑定到S:R:D)可能会使事情正常进行?

尝试添加wait for,然后单击该按钮webelement@AnkurSingh:我将find_元素调用包装在来自Selenium::water的wait_until中,但这没有帮助。
Error while executing command: executeScript: TypeError: xpathResult is null
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'myhost.de', ip: '178.xxx.yyy.zzz', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-042stab127.2', java.version: '1.8.0_172'
Driver info: driver.version: unknown at /usr/local/share/perl/5.20.2/Selenium/Remote/Driver.pm line 313.
 at /usr/local/share/perl/5.20.2/Selenium/Remote/Driver.pm line 313.