Login and Logout Example in WebDriver :-

0


package scs;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class EfixmanLogin {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","c:\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("http://efixman.com//customer/login");
    WebElement txtname = driver.findElement(By.name("customerEmail"));
    txtname.sendKeys("test@gmail.com");
    WebElement txtpass = driver.findElement(By.name("customerPassword"));
    txtpass.sendKeys("12345");
    WebElement btn = driver.findElement(By.className("login100-form-btn"));
    btn.click();
    driver.findElement(By.linkText("Logout")).click();
    driver.switchTo().alert().accept();
}
}
//Key Point:-    By.className() :-   if name,id is not available in HTML elements then we can use class locator in web driver 
driver.switchTo().alert() :-  It is used to manage alert box and press ok button.


Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)