簡體   English   中英

如何使用Selenium 2 Webdriver打開指定的配置文件Firefox?

[英]How to open specified profile Firefox with Selenium 2 Webdriver?

當我使用默認配置文件啟動沒有問題。 但是當我開始使用自定義配置文件時,firefox會啟動但仍會“阻止”。 該過程保持活動消耗31MB的RAM,但永遠不會啟動。 只有在我殺死這個過程后才開始,然后開始並與硒一起正常工作。

我使用Windows 7,Firefox 25.0.1和selenium-server-standalone-2.38.0.jar¿可能是版本兼容性問題?

這是打開配置文件的代碼:

FirefoxProfile profile = new FirefoxProfile(new File("C:/Users/UserTest/AppData/Roaming/Mozilla/Firefox/Profiles/tydtn9km.testprofile"));                  
WebDriver driver = new FirefoxDriver(profile);

編輯:這是我的實際代碼

package org.openqa.selenium.example;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

public class Main  {
    public static void main(String[] args) {
        ProfilesIni profile = new ProfilesIni();
        FirefoxProfile ffprofile = profile.getProfile("Other");
        WebDriver driver = new FirefoxDriver(ffprofile);
        driver.get("http://google.com");
    }
}

編輯2:已解決問題是由於我的Firefox配置文件位於另一個分區,而Firefox位於另一個分區中。

我一直在用它:

首先,創建一個Firefox配置文件,並以某種方式命名它。 例如SELENIUM

然后初始化您的個人資料:

ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM