Monday 23 May 2022

Selenium Locators Tutorial Part 2 | Selenium Locators with Examples | css selector xpath in Selenium

                  In this post, we will see Selenium Locators Tutorial Part 2 | Selenium Locators with Examples | css selector xpath in Selenium 


Program Code:


import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;


public class Locators2 {


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.cssSelector("input[id='login1']")).sendKeys("abc");

driver.findElement(By.cssSelector("input[id*='log']")).sendKeys("abc");

//driver.findElement(By.xpath("//input[@type='password']")).sendKeys("1234");

driver.findElement(By.xpath("//input[contains(@type,'word')]")).sendKeys("1234");

driver.findElement(By.cssSelector("input[title='Sign in']")).click();


}


}


   Watch following video:



No comments:

Post a Comment