Javascript Selenium测试自动化:jquery选择并验证文本是否存在?
我正在使用selenium编写测试自动化,如何使用jquery从一个表中选择9.0GB并验证表中存在的文本9.0GB 我需要做的就是让jquery查看表中的特定文本,并验证文本是否存在。下面是DOM:Javascript Selenium测试自动化:jquery选择并验证文本是否存在?,javascript,jquery,Javascript,Jquery,我正在使用selenium编写测试自动化,如何使用jquery从一个表中选择9.0GB并验证表中存在的文本9.0GB 我需要做的就是让jquery查看表中的特定文本,并验证文本是否存在。下面是DOM: <table id="usage-detail-table" class="table table-bordered table-striped table-hover footable tablefiltering footable-loaded dataTable no-footer d
<table id="usage-detail-table" class="table table-bordered table-striped table-hover footable tablefiltering footable-loaded dataTable no-footer default" role="grid">
<thead>
<tbody>
<tr class="odd" role="row">
<tr class="even" role="row">
<td class="nowrap sorting_1 expand">
<td class=" nowrap">Primary</td>
<td class=" nowrap">
<input type="hidden" value="9000010800">
9.0 GB
</td>
<td class=" nowrap">
<input type="hidden" value="8000000000">
8.0 GB
</td>
<td class=" nowrap">
<td class=" nowrap">
</tr>
<tr class="odd" role="row">
<tr class="even" role="row">
</tbody>
</table>
您可以尝试使用过滤器。例如:
var result = '';
$('td').filter(function() {
if($(this).html().indexOf('9.0 GB') >= 0){
result = "Got";
}
});
console.log(result);
关于jQuery的更多信息非常感谢您的回答。我其实是个新手。您是否了解一些关于Selenium自动化测试的知识。通常我们用以下格式编写代码:JavascriptExecutor driver.executeScriptjQuery'dhcp-lease-xlan'。触发器'change';我将如何使用上述格式实现您的代码?先谢谢你。