Listen to this blog
In Selenium, every HTML object is considered as WebElement. As an automation tester, you should be aware of what are all the applicable actions and validations for each HTML objects. In this blog article, you will learn all Selenium’s action and validation snippets for TextBox. As per W3C, a mutable HTML textbox should allow the user to edit value and it should not allow Line Feed & Carriage return characters.
Let’s start from some basics commands.
IsEnabled & ReadOnly
Before checking whether a textbox is enabled or readonly, you should know what is the difference between disabled and readonly textbox.
Readonly – If a textbox is readonly, you can still send the textbox’s content when a form is submitted and access the textbox using TAB key.
Disabled – If a textbox is disabled, the textbox’s content will not be sent when a form is submitted, you can’t access the textbox using TAB key, and the events like click, hover, & double click will not be triggered.
isReadOnly = txtBox.getAttribute("readonly"); isEnabled = txtBox.isEnabled();
Retrieving value from a textbox using Selenium is a cake walk for many. However, we, as an automation test company, would like to list it here. So that this blog article will be a quick reference guide for software testers who are learning Selenium.
value = txtBox.getAttribute("value");