Monday 23 May 2022

Selenium Locators Tutorial Part 1 | Selenium Locators with Examples | id, name, class name,link text

                  In this post, we will see Selenium Locators Tutorial Part 1 | Selenium Locators with Examples | id, name, class name,link text 


Program Code: 

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;


public class Locators1 {


public static void main(String[] args) 

{

System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver_win32\\chromedriver.exe");

WebDriver driver=new ChromeDriver();

driver.get("https://mail.rediff.com/cgi-bin/login.cgi");

driver.findElement(By.id("login1")).sendKeys("abc");

driver.findElement(By.name("passwd")).sendKeys("1234");

driver.findElement(By.className("lblkeepme")).click();

driver.findElement(By.className("signinbtn")).click();

System.out.println(driver.findElement(By.id("div_login_error")).getText());

//driver.findElement(By.linkText("Forgot Password?")).click();

driver.findElement(By.partialLinkText("Password")).click();

driver.navigate().back();

driver.navigate().forward();


}


}


    Watch following video:

No comments:

Post a Comment