How can I get the current input of a textbox on a page without saving the information, e.g if i want to edit something without saving, how can I verify my input String is entered into the textbox
N.B I am not allowed to save the form in this scenario. The problem is getText(); against the box will just return an empty string because this must be essentially the saved value, but I haven't saved yet.
public boolean checkTextBoxMaxLength(String Textbox, int maxLength) {
int overMaxLength = maxLength + 1;
char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
StringBuilder sb = new StringBuilder();
Random random = new Random();
for (int i = 0; i < overMaxLength; i++) {
char c = chars[random.nextInt(chars.length)];
sb.append(c);
}
String output = sb.toString();
System.out.println(output);
WebElement ele = driver.findElement(By.id(Textbox));
ele.clear();
ele = driver.findElement(By.id(Textbox));
String maximum = ele.getAttribute("maxlength");
System.out.println("Element maxlenght is: " +maximum);
ele.sendKeys(output);
String input = ele.getText();
if (input.equals(output.substring(0,output.length()-1))) {
return true;
} else {
return false;
}
}
In the above scenario, input will always equal " " as nothing has been saved, is there a simple solution to get the text as it currently exists pre-save?