0
我的程序在遇到確認框時失敗。我需要點擊確認框才能繼續。我無法挖掘到它的Html(使用螢火蟲)或其他。有人請讓我知道如何處理這種情況? 即使這樣事先沒有工作使用硒點擊瀏覽器確認框
enter code here
DesiredCapabilities capabilities;
capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("takesScreenshot", false);
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"/usr/local/bin/phantomjs");
WebDriver myTestDriver = new PhantomJSDriver(capabilities);
myTestDriver.manage().window().maximize();
myTestDriver.findElement(By.xpath("//input[@value = 'confirm']")).click();
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
Alert javascriptconfirm = myTestDriver.switchTo().alert();
javascriptconfirm.accept();
Selenium Web Driver : Handle Confirm Box using Java
感謝