1
的Html獲取輸入標籤編號,webdriver的價值用java
<table id="tblRenewalList" class="adminlist dataTable" width="100%" cellspacing="1" cellpadding="1" border="1" style="margin-left: 0px; width: 100%;" aria-describedby="tblRenewalList_info">
<thead>
</thead>
<tbody role="alert" aria-live="polite" aria-relevant="all">
<tr class="odd">
<td class="alignCenter">
<input id="chkRenewal_868" class="chkPatent" type="checkbox" onclick="RenewalSelection(this)" companyid="33" value="868">
</td>
</tr>
</table>
以上的Html我想刮id, value
下面是我的Java代碼,當我用下面的代碼嘗試,它的返回空值,請找代碼
WebElement inputValues = driver.findElement(By
.xpath("//*[@id='tblRenewalList']/tbody/tr[1]/td[1]"));
String idValue = inputValues.getAttribute("id");
String ed2 = inputValues.getAttribute("value");
以下是我期望的輸出
ID = chkRenewal_868 值= 868
由於將改變X路徑,達到我的預期 – Prabu