-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample12_1.java
More file actions
39 lines (29 loc) · 1.2 KB
/
Example12_1.java
File metadata and controls
39 lines (29 loc) · 1.2 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
package com.SeleniumTestingSamples.Examples;
import java.time.Duration;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//OPEN SINGLE WINDOW
public class Example12_1 {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new ChromeDriver();
driver.get("https://www.leafground.com/window.xhtml");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10000));
String oldWindow = driver.getWindowHandle();
System.out.println("Parent Window Handle:"+ oldWindow);
//Click New Window button
WebElement firstButton = driver.findElement(By.xpath("//*[@id=\'j_idt88:new\']/span"));
firstButton.click();
Set<String> handles = driver.getWindowHandles();
System.out.println("Window Handles: " + handles);
for(String newWindow: handles) {
driver.switchTo().window(newWindow);
}
// Enter value in Email Address Text box
WebElement textBox = driver.findElement(By.xpath("//*[@id=\'email\']"));
textBox.sendKeys("mcavit@gmail.com");
}
}