简体   繁体   English

Robot Framework - 从表中获取跨度元素

[英]Robot Framework - get span element from table

I'm trying to write some test cases to automatically test my websites but I'm having trouble clicking on checkbox witch is situated on every single row in the left column.我正在尝试编写一些测试用例来自动测试我的网站,但是我在单击位于左列中每一行的复选框时遇到问题。 User can click on every cell in the row he wants and checkbox will became checked or unchcked..用户可以点击他想要的行中的每个单元格,复选框将被选中或取消选中。

But I'm not able to simulate this click into table cell.但我无法模拟这个点击表格单元格。 First I'm trying to get some cell into variable and then to click on this cell using this variable like this:首先,我试图将一些单元格放入变量中,然后使用此变量单击此单元格,如下所示:

    Page Should Contain Element     xpath=//div[contains(@id,'-tableCtrlCnt')]
    ${item1}    Get Table Cell  xpath=//div[contains(@id,'-tableCtrlCnt')]/table/tbody  1   2
    Click Element   ${item1}

But I'm getting error on the second line of code, I just cannot get the column.但是我在第二行代码中遇到错误,我只是无法获取该列。
The error/fail is:错误/失败是:

Cell in table xpath=//div[contains(@id,'-tableCtrlCnt')]/table/tbody in row #2 and column #2 could not be found.找不到表 xpath=//div[contains(@id,'-tableCtrlCnt')]/table/tbody 中的第 #2 行和第 #2 列中的单元格。

And this is how part of my html code looks like:这就是我的 html 代码的一部分的样子:

<div id="__table1-tableCtrlCnt" class="sapUiTableCtrlCnt" style="height: 160px;">
<table id="__table1-table" role="presentation" data-sap-ui-table-acc-covered="overlay,nodata" class="sapUiTableCtrl sapUiTableCtrlRowScroll sapUiTableCtrlScroll" style="min-width:648px">
<tbody>
<tr id="__table1-rows-row0" data-sap-ui="__table1-rows-row0" class="sapUiTableRowEven sapUiTableTr" data-sap-ui-rowindex="0" role="row" title="Click to select or press SHIFT and click to select a range" style="height: 32px;">
<td role="rowheader" aria-labelledby="__table1-ariarowheaderlabel" headers="__table1-colsel" aria-owns="__table1-rowsel0"></td>
<td id="__table1-rows-row0-col0" tabindex="-1" role="gridcell" headers="__table1_col0" aria-labelledby="__table1-0" style="text-align:left" class="sapUiTableTd sapUiTableTdFirst">
  <div class="sapUiTableCell">
  <span id="__text37-col0-row0" data-sap-ui="__text37-col0-row0" title="1010"   class="sapMText sapMTextMaxWidth sapMTextNoWrap sapUiSelectable" style="text-align:left">1010
  </span>
  </div>
</td>
<td id="__table1-rows-row0-col1" tabindex="-1" role="gridcell" headers="__table1_col1" aria-labelledby="__table1-1" style="text-align:left" class="sapUiTableTd">
  <div class="sapUiTableCell">
  <span id="__text38-col1-row0" data-sap-ui="__text38-col1-row0" title="Company Code 1010" class="sapMText sapMTextMaxWidth sapMTextNoWrap sapUiSelectable" style="text-align:left">Company Code 1010
  </span>
  </div>
</td>
</tr>
...
</tbody>
</table>
</div>

Don't you have any idea how to solve this click into table issue?你不知道如何解决这个点击进入表格的问题吗?

Check whether this helps you-检查这是否对您有帮助-

${item1}    Get Table Cell  xpath=//table[contains(@id,'__table1-table')]  1   2

OR或者

${item1} = Get Text //table[contains(@id,'__table1-table')]//tr[1]//td[2]//div/span ${item1} = Get Text //table[contains(@id,'__table1-table')]//tr[1]//td[2]//div/span

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM