input输入框DOM结构:
尝试用element.getText(),调试后,取值失败。查阅资料,总结如下:
1、通过元素属性来获取值
String value = username.getAttribute("value");
2、通过js来获取值
JavascriptExecutor js = (JavascriptExecutor) driver;
String value = (String)js.executeScript("return arguments[0].value;",username);
3、通过JQuery来获取值
JavascriptExecutor js = (JavascriptExecutor) driver;
(1):String value = (String)js.executeScript("return $('#username').attr('value');");
(2):String value = (String)js.executeScript("return $('#username').val();");
END