HOW TO VERIFY SINGLE CHECKBOX IN A WEBPAGE USING SELENIUM?

kosmikkosmik Member
  • Open the Firefox browser
  • Navigate the AppUrl
  • Identify Checkbox1
  • Select Checkbox1
  • Verify Checkbox1
  • Close the current Browser window

Selenium Code : --------------------

package seleniumProject;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver; 

public class VerifyCheckbox { public static void main(String[] args) {  

//open the firefox browser

WebDriver Driver = new FirefoxDriver();  

//navigate the AppUrl

Driver.get("http://demo.guru99.com/test/radio.html");

// Identify Checkbox1 WebElement CheckBox1= Driver.findElement(By.id("vfb-6-0"));

//Select Checkbox1 CheckBox1.click();   

//Verify Checkbox1

if (CheckBox1.isSelected()) { System.out.println("Checkbox1 Selected"); } else { System.out.println("Checkbox1 not Selected"); }  

//Close the current Browser window

Driver.close(); } }

FOR More information click on below link

http://bit.ly/2ZwG9vC

Sign In or Register to comment.