I have a modal window with some textboxes in it. I used to input text using className to get all the form field and indexing the textboxes. Nowadays, the modal has changed and dev provided me with an ID for each box. What I'm trying to do it's just to input text and click a Submit button, but what happens is that sometimes, the String is inserted partially.
Let's say I want to input "System1" string, but sometimes the WebDriver inputs "Sys", or "Sy"etc.. and then goes for the click
I've tried to locate Element via ID, XPATH... but the point is that I can see how the text is on the field so the element is located properly
There is another issue as well. To make sure what the textbox contains after the .senKeys() method, I put and assert which supposedly gets the text from the textbox via .getText() method and compares it with the String I'm passing to the main method, but I'm getting null at this point, and I can see how functionally the WebDrivers input something, complete or not Please note that I'm using the same WebElement object to both .sendKeys() and .getText() methods
Here's the code I'm running, simple AF:
//Locating the TextBox
@FindBy(how = How.ID, using = "text")
public WebElement nameField;
public void introducirEnCampoNombre(String name) {
//nameField.clear();
nameField.sendKeys(name);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String xpectedString = nameField.getText();
Assert.assertEquals(name, xpectedString);
}
Here is the related HTML code:
<form id="systemForm" action="/ik-conf/systemAction/save" method="POST">
<input id="id" name="id" type="hidden" value="">
<input id="parentNode.id" name="parentNode.id" type="hidden" value="1">
<div class="row">
<div class="left lv-text-label">
<label for="text" class="right-label inline">Nombre(*):</label>
</div>
<div class="right lv-text-input">
<input id="text" name="text" autofocus="autofocus" validation="/ik-conf/system/nameValidation" class="ikconf-fieldset width_100x100" type="text" value="">
</div>
</div>
<div class="row">
<div class="left">
<label for="description" class="right-label inline">Descripción:</label>
</div>
<div class="right">
<textarea id="description" name="description" style="margin-bottom:0px;" class="width_100x100 z-label" rows="3" cols="40"></textarea>
</div>
</div>
So as I said above, the code goes for the submit button (which is in the next method) before the string is inserted properly. When debugging, I can check that the string is correct, and then is the second issue. I try to locate again the same element with another name INSIDE the method but same result, .getText() returns me null
Hope someone could bring some light over here.
Thanks in advance