Skip to content Skip to sidebar Skip to footer

Verify Typed Text In Input Text - Selenium

I have a simple method for sending keys to a textbox, but sometimes the end letters are missing, or the whole text, yet selenium returns 'Passed' for this test step. This happens o

Solution 1:

On sending keys to a textbox and trying to verify right after the text is typed if it equals to the expected text will always returnnull and that is the Expected Behavior.

Reason

When you invoke sendKeys(), it simply pastes the Character String within the textbox. No other action is performed and nothing is returned. So no change in the HTML DOM.

So, when you try to do :

textboxelement.getText()

null is returned.

Incase when you click on Save button the onClick() event of Save button performs the intended functions (calls to JavaScript / AJAX Scripts) which inturn changes the HTML DOM and the text is gets accomodated with the DOM Tree. Now if you try to :

textboxelement.getAttribute("attribute_name");

You would be able to retrive the text.

Finally, as you mentioned without pressing a key like ENTER because it might close this dialog window that is how the text would be accomodated in the DOM Tree for Selenium and your Automation Script to find out through findElement() or findElements()

Post a Comment for "Verify Typed Text In Input Text - Selenium"