Selenium 指定瀏覽器位置


在腳本開頭要指定瀏覽器位置.

 1 public static void main(String[] args) throws InterruptedException, IOException {
 2            System.setProperty("webdriver.gecko.driver", "D:\\geckodriver-v0.19.1-win64\\geckodriver.exe");
 3            ProfilesIni pi = new ProfilesIni();
 4            FirefoxProfile profile = pi.getProfile("default");
 5            FirefoxOptions options = new FirefoxOptions();
 6            options.setProfile(profile);
 7         WebDriver driver = new FirefoxDriver(options);
 8         driver.manage().window().maximize();
 9         driver.get("http://www.baidu.com");        
10         System.out.println(driver.getTitle());

不需要在腳本中指定瀏覽器位置的情形:

1. 瀏覽器安裝在默認位置

2. 瀏覽器已添加在path中(i.e. 已配置環境變量)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM