Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

STQA Practical no 8

~Made by Shlok Punekar


Code:
package prac8;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.*;

public class practicalno8 {


public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Administrator\\Downloads\\
chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://demo.guru99.com/test/login.html";
driver.get(baseUrl);
WebElement email = driver.findElement(By.id("email"));
WebElement password = driver.findElement(By.id("passwd"));
email.sendKeys("gogoagon@gmail.com");
password.sendKeys("gongonegoner");
System.out.println("TextField Set");

email.clear();
password.clear();
System.out.println("Text Field Cleared");

WebElement login = driver.findElement(By.id("SubmitLogin"));


email.sendKeys("gogoagon@gmail.com");
password.sendKeys("gongonegoner");
login.click();

System.out.println("Login done with click");


driver.get(baseUrl);

driver.findElement(By.id("email")).sendKeys("gogoagon@gmail.com");
driver.findElement(By.id("passwd")).sendKeys("gongonegoner");
driver.findElement(By.id("SubmitLogin")).submit();
System.out.println("login done with Submit fucntion");

driver.get("http://demo.guru99.com/test/radio.html");
WebElement rad1 = driver.findElement(By.id("vfb-7-1"));
rad1.click();
System.out.println("Radio Button 1 Selected");
WebElement rad2 = driver.findElement(By.id("vfb-7-2"));
rad1.click();
System.out.println("Radio Button 2 Selected");

WebElement check = driver.findElement(By.id("vfb-6-0"));


check.click();

if (check.isSelected()) {
System.out.println("CheckBox is toggled on.");
}
else {
System.out.println("CheckBox is toggled off");
}

driver.get("http://demo.guru99.com/test/facebook.html");
WebElement persist = driver.findElement(By.id("persist_box"));

for(int i=0;i<2;i++) {
persist.click();
System.out.println("Facebook Persists CheckBox Status is - "+persist.isSelected());
}
driver.close();
}

You might also like