-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample5.java
More file actions
49 lines (39 loc) · 1.74 KB
/
Example5.java
File metadata and controls
49 lines (39 loc) · 1.74 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
package com.SeleniumTestingSamples.Examples;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//Radio Button
//Methods - isSelected() and Click()
public class Example5 {
public static void main(String[] args) throws InterruptedException {
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 usernamel = driver.findElement(By.name("username"));
WebElement password1 = driver.findElement(By.name("password"));
usernamel.sendKeys("Admin");
password1.sendKeys("admin123");
WebElement submit = driver.findElement(By.xpath("//*[@id=\'app\']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button"));
submit.click();
Thread.sleep(5000);
WebElement myInfo = driver.findElement(By.xpath("//*[@id=\'app\']/div[1]/div[1]/aside/nav/div[2]/ul/li[6]/a/span"));
myInfo.click();
WebElement radio1 = driver.findElement(By.xpath("//*[@id='app']/div[1]/div[2]/div[2]/div/div/div/div[2]/div[1]/form/div[3]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div/label/span") );
boolean selectState = radio1.isSelected();
if(!selectState) {
radio1.click();
}
//Page scroll down
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy (0,250)");
Thread.sleep(5000);
//Page scroll up
JavascriptExecutor jse1 = (JavascriptExecutor) driver;
jse1.executeScript("window.scrollBy(0,-250)");
}
}