Initiating the Web Driver and Navigate to the Webpage

Further, we will define the location of ChromeDriver inside the setProperty function and initiate the ChromeDriver. Here, we have opened the Geeks for Geeks website (link) using the get() method.

get()

The get() method navigates the user to a certain webpage stated by him by opening that webpage in the respective browser.

Java




//Import selenium libraries
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
 
public class selenium4 {
    public static void main(String[] args) {
          
            // State the chromedriver URL 
           System.setProperty("webdriver.chrome.driver","C:\\Users\\Vinayak Rai\\Downloads\\chromedriver-win64\\chromedriver-win64\\chromedriver.exe");
      
           // Define and initiate the chrome driver
           WebDriver driver = new ChromeDriver();
            
           // Open the Geeks For Geeks website
       }
}


Selenium Webdriver Handling Checkbox using Java

A set of tools and libraries that allow the user to automate interactions with web browsers is known as Selenium. It is too diverse tool that can handle every operation of a webpage starting from opening the webpage to closing of webpage. In this article, we will see the various steps to handle the checkboxes using Selenium webdriver in Java.

Similar Reads

Steps of Selenium Webdriver Handling Checkbox Using Java

Certain steps need to be followed to handle the checkbox using Selenium webdriver in Java....

Setting up the Selenium in Java

For setting up Selenium in Java, you need to download the Selenium JARs from the official website of Selenium. Add those JARs under the Add external JARs available under the Configure Build Path section....

Installing the Necessary Modules

Now, the crucial modules that are needed for scrolling a webpage in Java are WebElement, WebDriver, By, and ChromeDriver. We import all these modules now....

Initiating the Web Driver and Navigate to the Webpage

Further, we will define the location of ChromeDriver inside the setProperty function and initiate the ChromeDriver. Here, we have opened the Geeks for Geeks website (link) using the get() method....

Finding an Element

...

Click on an Element

Once the website is loaded, we will now find an element, i.e., checkboxes, that needs to be handled using the findElement, By.xpath and contains function....

Check if the Element is Selected

...

Conclusion

Finally, we will click on the checkboxes check_box1 and check_box2, that we found in the previous step using the click function....

FAQs

...