0% found this document useful (0 votes)
4 views4 pages

Raj Singh Locator

The document contains Java code examples for using Selenium WebDriver to automate login processes on two different websites: Guru99 and OrangeHRM. Each code snippet sets up the ChromeDriver, navigates to the respective URL, inputs login credentials, and performs logout actions. Additionally, it includes a reference to adding necessary jar files for the Selenium library.

Uploaded by

zennuggetsz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Raj Singh Locator

The document contains Java code examples for using Selenium WebDriver to automate login processes on two different websites: Guru99 and OrangeHRM. Each code snippet sets up the ChromeDriver, navigates to the respective URL, inputs login credentials, and performs logout actions. Additionally, it includes a reference to adding necessary jar files for the Selenium library.

Uploaded by

zennuggetsz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

202-D-RAJ SINGH

LOCATOR

Code:

package Assignmet12;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class Demolocator {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", "D:\\sachin\\chromedriver.exe");

WebDriver wd = new ChromeDriver();

wd.get("http://demo.guru99.com/test/newtours/");

wd.findElement(By.name("userName")).sendKeys("Admin123");

wd.findElement(By.name("password")).sendKeys("admin123");

wd.findElement(By.name("submit")).click();

try {

Thread.sleep(5000);

} catch (InterruptedException e) {

e.printStackTrace();

wd.quit();

Output:
202-D-RAJ SINGH

2. Locator with orange HRM


202-D-RAJ SINGH
Code:

package Assignmet12;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class LocatorsProgram {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", "D:\\sachin\\chromedriver.exe");

WebDriver wd = new ChromeDriver();

wd.get("https://opensource-demo.orangehrmlive.com/");

wd.manage().window().maximize();

wd.findElement(By.name("username")).sendKeys("Admin");

wd.findElement(By.name("password")).sendKeys("admin123");

wd.findElement(By.xpath("//button[@type='submit']")).click();

wd.findElement(By.xpath("//span[text()='Welcome']")).click();

wd.findElement(By.linkText("Logout")).click();

wd.quit();

Output:
202-D-RAJ SINGH

Adding jar files

You might also like