
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to select checkboxes using selenium java webdriver?
We can select the checkbox with Selenium. In an html document, each checkbox has an attribute type set to a value as checkbox. In order to select a checkbox, we shall first identify a checkbox with any locator and then apply the click() method to it.
Example
Code Implementation.
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class CheckBoxSelect{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url ="https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm"; driver.get(url); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); // identify element WebElement l=driver.findElement(By.xpath("//*[@value='Manual Tester']")); // select checkbox with click() l.click(); driver.quit(); } }
Output
- Related Questions & Answers
- How to Select Value from DropDown using Selenium Webdriver?
- How to select an item from a dropdown list using Selenium WebDriver with java?
- Handling DropDown And Multiple Select in Webdriver using Selenium
- How to Select date from a datepicker with Selenium Webdriver using Python?
- How to handle frame in Selenium WebDriver using java?
- How to scroll down using Selenium WebDriver with Java?
- How to use clickandwait in Selenium Webdriver using Java?
- How to select the Date Picker In Selenium WebDriver?
- How to perform mouseover function in Selenium WebDriver using Java?
- How to type in textbox using Selenium WebDriver with Java?
- How to get selected option using Selenium WebDriver with Java?
- How to handle authentication popup with Selenium WebDriver using Java?
- How to Verify Tooltip using Selenium WebDriver?
- How to upload files using Selenium Webdriver?
- Switch tabs using Selenium WebDriver with Java.
Advertisements