0
我試圖進入本網站的主頁。當我這樣做時,我被一個彈出窗口阻止,其中有一個我需要點擊的鏈接。只有這樣我才能進入。我能夠處理,直到彈出使用下面的代碼,但無法處理如何點擊彈出窗口中出現的鏈接。該彈出窗口不是基於瀏覽器的。誰能幫我。附件爲您的參考通過硒webdriver彈出處理鏈接
package com.certipath;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class handlingPopupAlert {
public static void main(String[] args) throws InterruptedException {
File file = new File("C:\\Selenium\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver= new InternetExplorerDriver();
Thread.sleep(3000);
//Opens web page
driver.get("https://staging.trust-test.local/Home");
// Switching to Alert
Alert alert=driver.switchTo().alert();
// Capturing alert message.
String alertMessage=driver.switchTo().alert().getText();
// Displaying alert message
System.out.println(alertMessage);
System.out.println(alertMessage)的結果是什麼;? – kushal