Geb Select 基于文本的标签
Geb Select a tag based on text
我正在尝试 select 基于文本,我使用以下内容 select
$("div[class='ui-datatable-tablewrapper']").find("span:contains('Person Name')")
我收到以下错误:
Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified
我认为这是因为 "contains" select 或 jquery。我如何在 geb 中实现相同的效果。
Html:
<div class="ui-datatable-tablewrapper">
<table role="grid">
<thead id="searchForm:singleStaffDT_head">
<tr role="row">
<th id="searchForm:singleStaffDT:j_id_7s" class="ui-state-default" role="columnheader"
aria-label="Person ID" scope="col" style="width:15%">
<span class="ui-column-title">Person ID</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7u" class="ui-state-default" role="columnheader"
aria-label="Person Name" scope="col" style="width:25%">
<span class="ui-column-title">Person Name</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7w" class="ui-state-default" role="columnheader"
aria-label="Organization" scope="col" style="width:25%">
<span class="ui-column-title">Organization</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7y" class="ui-state-default" role="columnheader"
aria-label="Staff Role" scope="col" style="width:25%">
<span class="ui-column-title">Staff Role</span>
</th>
<th id="searchForm:singleStaffDT:j_id_80" class="ui-state-default" role="columnheader"
aria-label="" scope="col" style="width:10%">
<span class="ui-column-title">Action
<BR />[Select]</span>
</th>
</tr>
</thead>
<tbody id="searchForm:singleStaffDT_data" class="ui-datatable-data ui-widget-content">
<tr class="ui-widget-content ui-datatable-empty-message">
<td colspan="5"></td>
</tr>
</tbody>
</table>
</div>
对于 "contains" 搜索,您希望以与此类似的模式编写代码:
$("span", text: contains("Person Name"))
您也可以在您的页面对象中执行类似的操作(我认为!):
personName { $('span').find(text: 'Person Name') }
或者:
personName { find('span', text: 'Person Name') }
我正在尝试 select 基于文本,我使用以下内容 select
$("div[class='ui-datatable-tablewrapper']").find("span:contains('Person Name')")
我收到以下错误:
Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified
我认为这是因为 "contains" select 或 jquery。我如何在 geb 中实现相同的效果。
Html:
<div class="ui-datatable-tablewrapper">
<table role="grid">
<thead id="searchForm:singleStaffDT_head">
<tr role="row">
<th id="searchForm:singleStaffDT:j_id_7s" class="ui-state-default" role="columnheader"
aria-label="Person ID" scope="col" style="width:15%">
<span class="ui-column-title">Person ID</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7u" class="ui-state-default" role="columnheader"
aria-label="Person Name" scope="col" style="width:25%">
<span class="ui-column-title">Person Name</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7w" class="ui-state-default" role="columnheader"
aria-label="Organization" scope="col" style="width:25%">
<span class="ui-column-title">Organization</span>
</th>
<th id="searchForm:singleStaffDT:j_id_7y" class="ui-state-default" role="columnheader"
aria-label="Staff Role" scope="col" style="width:25%">
<span class="ui-column-title">Staff Role</span>
</th>
<th id="searchForm:singleStaffDT:j_id_80" class="ui-state-default" role="columnheader"
aria-label="" scope="col" style="width:10%">
<span class="ui-column-title">Action
<BR />[Select]</span>
</th>
</tr>
</thead>
<tbody id="searchForm:singleStaffDT_data" class="ui-datatable-data ui-widget-content">
<tr class="ui-widget-content ui-datatable-empty-message">
<td colspan="5"></td>
</tr>
</tbody>
</table>
</div>
对于 "contains" 搜索,您希望以与此类似的模式编写代码:
$("span", text: contains("Person Name"))
您也可以在您的页面对象中执行类似的操作(我认为!):
personName { $('span').find(text: 'Person Name') }
或者:
personName { find('span', text: 'Person Name') }