-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample1_3.java
More file actions
62 lines (52 loc) · 1.97 KB
/
Example1_3.java
File metadata and controls
62 lines (52 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.SeleniumTestingSamples.Examples;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Example1_3 {
//TEXTBOX SCENARIO TO AUTOMATE
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
String url = "https://opensource-demo.orangehrmlive.com/web/index.php/auth/login";
driver.get(url);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10000));
driver.manage().window().maximize();
WebElement username1 = driver.findElement(By.name("username"));
WebElement password1 = driver.findElement(By.name("password"));
username1.sendKeys("Admin");
password1.sendKeys("admin123");
System.out.println("Text Field Values Set");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//Delete Text Field Values
username1.sendKeys(Keys.CONTROL+"a");
username1.sendKeys(Keys.DELETE);
password1.sendKeys(Keys.CONTROL+"a");
password1.sendKeys(Keys.DELETE);
System.out.println("Text Field Values deleted");
//Find Login Button and Click
WebElement submit = driver.findElement(By.xpath("//*[@id=\'app\']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button"));
username1.sendKeys("Admin");
password1.sendKeys("admin123");
submit.click();
System.out.println("Login Button Clicked");
//Find Logout button and click
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
driver.findElement(By.xpath("//*[@id=\'app\']/div[1]/div[1]/header/div[1]/div[3]/ul/li/span/p")).click();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
driver.findElement(By.xpath("//*[@id=\'app\']/div[1]/div[1]/header/div[1]/div[3]/ul/li/ul/li[4]/a")).click();
}
}