-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSActions2.java
More file actions
28 lines (24 loc) · 1018 Bytes
/
JSActions2.java
File metadata and controls
28 lines (24 loc) · 1018 Bytes
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
package VINDVG1.Vinay27;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class JSActions2 {
public static void main(String[] args) throws InterruptedException {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_prompt");
driver.manage().window().maximize();
WebElement iframe = driver.findElement(By.xpath("//*[@id=\"iframeResult\"]"));
driver.switchTo().frame(iframe);
driver.findElement(By.xpath("/html/body/button")).click();
String text = driver.switchTo().alert().getText();
System.out.println(text);
Thread.sleep(5000);
driver.switchTo().alert().sendKeys("Vinay Kumar");
driver.switchTo().alert().accept();
driver.switchTo().parentFrame();
System.out.println(driver.getTitle());
}
}