Selenium WebDriver supports the checkbox element using the WebElement interface.
01 Handling Checkboxes.
02 Handling Radio Buttons via customized xpath.
A form consists of various elements like text box, email field, password field, text area, radio buttons, checkbox, dropdowns, links, etc.

- Input Box – It consists of either a text field or an email field or a password field. The action which we can perform in a text box are:
- Passing Text – method used is sendKeys(“String”);
WebElement oUsername;
oUsername = oBrowser.findElement(By.id("u_0_1"));
//To clear the text
oUsername.clear();
//To enter string value in a text field
oUsername.sendKeys("Merisa");
- Clearing Text – method used is clear();
- Radio Button – Radio button allows you to select one option out of many. The Action which can be performed on a radio button is click().
//To select a radio button - click() method is used
Driver.findElement(By.id("u_0_f")).click();
- Checkbox – Checkbox allows multiple selections as well. A checkbox can be toggled ON/OFF by click() method.
//To toogle a checkbox - click method is used
Driver.findElement(By.xpath("//input[@type='checkbox']")).click();
- Links – Links in html are hyperlinks, clicking on a link will navigate you to another page or document.
- Dropdown – Dropdown is a web element which gives us many options to select from. Dropdown in HTML is represented by Select tag, and its elements are represented by option tag.
- Buttons – There are used to submit a form. Actions that can be performed on a button are click() and submit().
GOOGLE SIGNUP COMING SOON.
References:- Checkbox more examples
//To submit a button either click() or submit method is used
Driver.findElement(By.id("gh-btn")).click();
//or
Driver.findElement(By.id("gh-btn")).submit();
No comments:
Post a Comment