我的应用程序会自动在文本框中生成零。我想用sendkeys中的excel值替换/覆盖零值。我已经使用过replace,Control + a,双击甚至清除。但不幸的是没有用。任何帮助将不胜感激。
HTML
<td class="ui-panelgrid-cell" role="gridcell">
<label id="createShipmentForm2:j_idt368" class="ui-outputlabel ui-widget label-black-13-400 mandatoryField" for="createShipmentForm2:totalDeclaredValue" style="margin-left:20px;">
<br/>
<input id="createShipmentForm2:totalDeclaredValue" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all custom-input-field ui-state-hover" type="text" aria-required="true" style="width:260px;margin-left:20px;" onblur="PrimeFaces.ab({s:"createShipmentForm2:totalDeclaredValue",e:"blur",f:"createShipmentForm2",p:"createShipmentForm2:totalDeclaredValue"});" onchange="PrimeFaces.bcn(this,event,[function(event){PrimeFaces.ab({s:"createShipmentForm2:totalDeclaredValue",e:"change",f:"createShipmentForm2",p:"createShipmentForm2:totalDeclaredValue"});},function(event){PrimeFaces.ab({s:"createShipmentForm2:totalDeclaredValue",e:"change",f:"createShipmentForm2",p:"createShipmentForm2:totalDeclaredValue",u:"createShipmentForm2:insurancetextbox2"});}])" value="0" name="createShipmentForm2:totalDeclaredValue" role="textbox" aria-disabled="false" aria-readonly="false"/>
</td>
代码
//To store Auto generated value of TDV
String autogeneratedTDV=driver.findElement(By.id("createShipmentForm2:totalDeclaredValue")).getAttribute("value");
excel.printoutput(0, row, 2, autogeneratedTDV);
Thread.sleep(5000);
//To change the value of Total Declared value field
String TDV=excel.getNumericData(1, row, 31);
if (TDV!="")
{
driver.findElement(By.id("createShipmentForm2:totalDeclaredValue")).sendKeys(Keys.HOME,Keys.chord(Keys.SHIFT,Keys.END),TDV);
}
else
{
Thread.sleep(5000);
//driver.findElement(By.id("createShipmentForm2:totalDeclaredValue")).clear();
Actions builder = new Actions(driver);
builder.doubleClick(driver.findElement(By.id("createShipmentForm2:totalDeclaredValue"))).perform();
//String selectAll=Keys.chord(Keys.CONTROL,"a");
//driver.findElement(By.id("createShipmentForm2:totalDeclaredValue")).sendKeys(selectAll);
Thread.sleep(8000);
driver.findElement(By.id("createShipmentForm2:totalDeclaredValue")).sendKeys(excel.getNumericData(0, row, 2));
}