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
定位方法:
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++;
}