如何透過環境變數中的系統屬性配置 IE 驅動程式?
我們可以透過環境變數中的系統屬性配置 IE 驅動程式。首先,我們必須導航到該連結 − https://www.selenium.dev/downloads/。然後,根據我們可用的作業系統,單擊下載連結(32 或 64)。
下載完成後,將建立 zip 檔案。需要將其提取並儲存在某個位置。提取檔案後,可執行檔案 IEDriverServer.exe 將可用。
從開始選單進入環境變數。然後,單擊編輯系統環境變數,如下圖所示。
導航到系統屬性彈出視窗中的高階選項卡。然後,單擊環境變數。
環境變數彈出視窗開啟後,我們將移動到系統變數並選擇路徑變數,然後單擊編輯。
在編輯環境變數框中,選擇新建。
指定我們之前儲存在某個位置的 IE 驅動程式可執行檔案路徑。
範例
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.ie.InternetExplorerDriver; import java.util.concurrent.TimeUnit; public class IELaunch{ public static void main(String[] args) { WebDriver driver = new InternetExplorerDriver(); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://tutorialspoint.tw/index.htm"); } }
輸出
廣告