From the course: Test Automation with Selenium WebDriver for Java
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Solution: Complete a form
From the course: Test Automation with Selenium WebDriver for Java
Solution: Complete a form
(upbeat music) - [Instructor] There were three elements where you needed to type text, an input element with type text, an input element with type password, and a text area element. Regardless of the element, when you need to type text, sendKeys is the method to use. To select an option from the dropdown menu, I use the Select class and the selectByValue method. While I could have selected the option by visible text or index, I chose to selectByValue because the value is the least likely to change. To deselect the checked checkbox, I first verify that it was already selected, and then clicked it to deselect. To select the checkbox, I make sure the checkbox is not selected before attempting to click and select it. For radio buttons with the same name attribute, selecting one deselects the others, so I don't need to do any special validation here. I can simply click the radio button I want to select. Then, finally, to submit the form, I click the Submit button.