问题
I want to verify the value of specific class in HTML
code with Selenium IDE
, In the next code I want to get the value of: data-val
that under class called tgl
, in my example it can be 0
or 1
.
how can I do it with Selenium IDE
? How can I verify that the value is 0
or 1
?
<!DOCTYPE html>
<html>
<head>
<body id="rpt-page-control-wafd" data-dir="ltr" data-lang="en" dir="ltr">
<div id="wrapper">
<div id="nav" style="background-color: transparent;">
<div id="page-ext">
<div id="page-content">
<div id="page-main" class="module module-simple" style="left:0px;top:0px;width:1008px;height:532px;display:;">
<div id="wafd-t" class="cont cont-full" style="left: 0px; top: 91px; width: 1008px; height: 441px; background-color: transparent;">
<div class="cont-grid cont-grid-extended-header">
<table id="wafd-t-tblh" class="data-grid data-grid-header" style="background-color: transparent;">
<table id="wafd-t-tblb" class="data-grid data-grid-body" style="background-color: transparent;">
<tbody>
<tr class="" data-row="1">
<td class="col-idx" style="width:72px;" data-max="999.0" data-min="0.0" data-val="1" data-col="CONTROL_WATER_AND_FEED__Day">
<td class="hour editable" style="width:80px;" data-max="1440.0" data-min="0.0" data-val="01:01" data-col="CONTROL_WATER_AND_FEED__Time">
<td class="tgl" style="width: 60px; background-color: rgb(244, 244, 244);" data-val="0" data-col="water_1">
<td class="tgl" style="width: 60px; background-color: rgb(244, 244, 244);" data-val="0" data-col="water_2">
<td class="tgl" style="width: 60px; background-color: rgb(244, 244, 244);" data-val="1" data-col="water_3">
<td class="tgl" style="width:60px;" data-val="0" data-col="water_4">
<td class="tgl" style="width:60px;" data-val="0" data-col="feed_1">
<td class="tgl" style="width:60px;" data-val="1" data-col="feed_2">
<td class="tgl" style="width:60px;" data-val="0" data-col="feed_3">
<td class="tgl" style="width:60px;" data-val="0" data-col="feed_4">
<td class="tgl" style="width:60px;" data-val="0" data-col="auger_1">
<td class="tgl" style="width:60px;" data-val="0" data-col="auger_2">
<td class="tgl" style="width:60px;" data-val="0" data-col="auger_3">
<td class="tgl" style="width:60px;" data-val="0" data-col="auger_4">
<td class="col-edit" style="width:72px;" data-col="col_edit">
</tr>
<tr data-row="2">
<tr data-row="3">
<tr data-row="4">
<tr data-row="5">
<tr data-row="6">
<tr data-row="7">
</tbody>
</table>
<table id="wafd-t-tbl" class="data-grid" style="display: none;"></table>
<div id="wafd-t-tbl-vscroll" class="data-grid-vscroller" style="top: 64px; height: 330px; width: 872px; background-color: transparent;"></div>
</div>
</div>
<div id="wafd-s" class="cont cont-modal" style="left:8px;top:20px;width:992px;height:470px;display:none;">
</div>
</div>
<div id="page-overlay" style="display:none;"></div>
<div id="page-float-ext" style="display:none;">
</div>
<script src="js/common.js?v11">
<script src="js/plugins/plugin.numkeypad.js?v11">
<script src="js/plugins/plugin.timekeypad.js?v11">
<script src="js/plugins/plugin.passcodepanel.js?v11">
<script src="js/plugins/plugin.datagrid.js?v11">
<script src="js/plugins/plugin.settingspanel.js?v11">
<script src="js/plugins/plugin.helppanel.js?v11">
<script src="js/ESLNS/JSGlobals.js?v11">
<script src="js/ESLNS/DataServiceUtils.js?v11">
<script src="js/ESLNS/DataConverts.js?v11">
<script src="js/libs/moment.min.js">
<script src="js/page.control-wafd.js">
<script src="js/libs/jquery-2.0.3.min.js">
<script src="js/libs/highcharts.js">
<script src="js/libs/highcharts-more.js">
<script src="js/libs/yepnope.1.5.4-min.js">
<script src="js/libs/jquery.touchSwipe.min.js">
<script src="js/main.js">
</body>
</html>
回答1:
You can execute javascript
to accomplish this. runScriptAndWait
command allows you to verify the attribute value against a tag
. You just have to be careful about writing the script
runScriptAndWait
|document.querySelector("data-col='CONTROL_WATER_AND_FEED__Day'").getAttribute("data-val")
|1
来源:https://stackoverflow.com/questions/28610501/selenium-ide-verify-value-for-class