我试图处理模式弹出窗口,但无法处理,因此无法在页面上执行任何操作。
我尝试了以下代码:
public static void main(String args[]) throws InterruptedException {
driver=new FirefoxDriver();
driver.get("https://www.veritread.com/carrier/");
//clicking on the any load then popup will be open
driver.findElement(By.xpath("//article[1]")).click();
Thread.sleep(3000);
String popup=driver.getWindowHandle();
driver.switchTo().window(popup);
//Trying to get text
String str= driver.findElement(By.xpath("//*[@id=\"modalPopContainer\"]/div/div/detail/section[3]/h1")).getText();
System.out.println("Text of element: "+str);
}