Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
如何从“获取xpath”;页面应包含“;在使用RobotFramework和Selenium的网页中_Selenium_Xpath_Robotframework - Fatal编程技术网

如何从“获取xpath”;页面应包含“;在使用RobotFramework和Selenium的网页中

如何从“获取xpath”;页面应包含“;在使用RobotFramework和Selenium的网页中,selenium,xpath,robotframework,Selenium,Xpath,Robotframework,我正在为一个网页编写测试用例,该网页的主要焦点是一个表。我正在检查页面是否包含一个新条目,通过页面是否应该包含function,然后我想找到这个元素的xpath。我这样做是因为每个条目都被添加到表的末尾,所以我无法为它设置静态xpath,因为我不知道在每次运行这个特定测试之间会添加多少条目 提前谢谢 <table class="fw-table"> <thead> <tr class="affix-header"> <th class=

我正在为一个网页编写测试用例,该网页的主要焦点是一个表。我正在检查页面是否包含一个新条目,通过页面是否应该包含function,然后我想找到这个元素的xpath。我这样做是因为每个条目都被添加到表的末尾,所以我无法为它设置静态xpath,因为我不知道在每次运行这个特定测试之间会添加多少条目

提前谢谢

<table class="fw-table">
<thead>
   <tr class="affix-header">
      <th class="columnwidth-description">Email</th>
      <th>Account</th>
      <th>Signed up</th>
      <th>Number of invalid attempts</th>
   </tr>
</thead>
<tbody>
   <tr>
      <td>devtest</td>
      <td><a href="/#!/accounts/5">Account</a></td>
      <td>true</td>
      <td>0</td>
   </tr>
   <tr>
      <td>mhills__@bottomline.com</td>
      <td><a href="/#!/accounts/40">Account</a></td>
      <td>true</td>
      <td>1</td>
   </tr>

电子邮件
账户
签约
无效尝试次数
德夫特
真的
0
mhills@bottomline.com
真的
1.

搜索:xpath=//body/div[2]/div/div[2]/div[2]/div/div/table/tbody/tr[1]/td[1]

如果需要验证最后一个表行是否包含某些文本,可以使用
页面应包含元素
关键字,并提供一个xpath定位器,该定位器将查找包含文本的最后一个表行:

Page Should Contain Element    xpath=//table[@class="fw-table"]//tr[last()]//td[contains(text(),'bottomline')]

请共享相关HTML代码电子邮件帐户注册的无效尝试次数devtest true 0 mhills_u@bottomline.com true 1抱歉,公司防火墙阻止jscript从Bloadibgn。。我不能在我的电脑上发表评论,我正在使用我的手机。你如何定义“xpath”?有每个祖先的,或者使用id的,或者任何xpath都可以吗?finspin在谓词中使用last()是正确的。我将考虑的一个细微的选择是:元素文本应该是XPath=//table [@类=“FW表”] /tBys/Tr[LSTATE()] //TD [ 1 ] MyssSy@ @ ButoMuln.com