1. 获取input中value的值
html代码
<input id = "_easyui_textbox_input5" type = "text" class ="textbox-text autocomplete="off" validatebox-text" name = "deptName"value = "1111" >
定位方法:
driver.findElement(By.id("_easyui_textbox_input5")).getAttribute("value");
2. 获取input的文本值
html代码
<input id = "_easyui_textbox_input5" type = "text" class ="textbox-text validatebox-text" autocomplete="off"name = "deptName" >1111</input>
定位方法:
driver.findElement(By.id("_easyui_textbox_input5")).getText();
例如,获取的文本框内容是a=1111,获取文本框内容后,如果a<1113,则a++
String a = driver.findElement(By.id("_easyui_textbox_input5")).getAttribute("value");
System.out.println(a);
int b = Integer.valueOf(a);
//if
if(null != a && a < 1113){
b++;
System.out.println("输出数字是"+a);//输出结果是“1111输出数字是1112”
}
else{
System.out.println("1");
}
//for
for(int b1 = Integer.valueOf(a);b1 < 1113;b++ ){
System.out.println("输出数字是"+b1);//输出结果是“1111输出数字是1111输出数字是1112”
}
//while
while(b < 1113){
System.out.println("输出数字是"+b);//输出结果是“1111输出数字是1111输出数字是1112”
b++;
}