2015-04-24 29 views
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

回答

2

没有很好地形成文件,我不知道,知道,对于重要的webdriver但 的XPath必须

//*[@id='tblRenewalList']/tbody/tr[1]/td[1]/input 
+0

由于将改变X路径,达到我的预期 – Prabu