Skip to content

Instantly share code, notes, and snippets.

@veenadevi
Last active December 11, 2021 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veenadevi/9442ed5a492eba088ff214c9a18e1923 to your computer and use it in GitHub Desktop.
Save veenadevi/9442ed5a492eba088ff214c9a18e1923 to your computer and use it in GitHub Desktop.
Simple Selenium TestNG TestClass
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class LTPlayGroundTest {
@Test //TestNG Annotation
public void validateCheckBoxStatus (){
/**WebDriverManager is a open Source API to ease the Browser Initialisation .
We can skip driver exe path definition**/
WebDriverManager.chromedriver().setup();
//Chrome Browser Initialised
WebDriver driver= new ChromeDriver();
//Launch the URL
driver.get("https://www.lambdatest.com/selenium-playground/checkbox-demo");
//get the WebElement of Check Box
WebElement singleCheckBox= driver.findElement(By.id("isAgeSelected"));
//click that check box
singleCheckBox.click();
//Validate checkbox is selected or not
Assert.assertTrue(singleCheckBox.isSelected(),"Checkbox is not selected ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment