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

 一个怪瓜的自白 发布于 2023-02-11 12:08

当我使用默认配置文件启动没有问题.但是当我开始使用自定义配置文件时,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位于另一个分区中.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有