selenium3 firefox启动firefox怎么加载多个配置

13:56 提问
selenium+python 启动浏览器后无法加载配置文件
代码如下:author = 'Jessie Lee'
from selenium import webdriver
driver = webdriver.Firefox()
driver.get(url)
driver.find_element_by_id("kw").send_keys("selenium2")
driver.find_element_by_id("su").click()
driver.quit()
运行以上代码 启动浏览器后 报错:
mon.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: c:\users\jessie~1\appdata\local\temp\tmpbdgm61 If you specified a log_file in the FirefoxBinary constructor, check it for details.
浏览器效果如下:
求大神帮忙啊 什么原因导致的
python 2.7 版本的 浏览器最新版本
按赞数排序
其他相关推荐共被编辑 3 次
Firefox有一个叫profile的东西。默认在C:\Users\张三\AppData\Roaming\Mozilla下。profile里保存了你的浏览器设置、收藏夹、插件配置==。点Firefox快捷方式启动时会默认读取一个叫default的profile。但selenium启动的Firefox好像默认不会读取default的配置,而是自己建立一个全新的profile。关掉firefox,进入firefox安装目录打cmd命令: firefox.exe --p就会看到弹出一个profile配置界面。
你需要给你的driver指定一个profile,这样启动firefox后,界面就是你指定的那个profile的样子了。具体方法可以百度:Python selenium profile。别问我为什么知道这些,我刚从坑里爬出来。
Firefox有一个叫profile的东西。默认在C:\Users\张三\AppData\Roaming\Mozilla下。profile里保存了你的浏览器设置、收藏夹、插件配置==。点Firefox快捷方式启动时会默认读取一个叫default的profile。但selenium启动的Firefox好像不会读取default的配置,而是自己建立一个全新的profile。关掉firefox,进入firefox安装目录打cmd命令: firefox.exe --p就会看到弹出一个profile配置界面。
你需要给你的driver指定一个profile,这样启动firefox后,界面就是你指定的那个profile的样子了。具体方法可以百度:Python selenium profile。别问我为什么知道这些,我刚从坑里爬出来。
Firefox有一个叫profile的东西。默认在C:Users张三AppDataRoamingMozilla下。profile里保存了你的浏览器设置、收藏夹、插件配置==。Firefox启动时会自动读取一个叫default的profile。关掉firefox,进入firefox安装目录打cmd命令: firefox.exe --p就会看到弹出一个profile配置界面。
你可以给你的driver指定一个profile,这样启动firefox后,界面就是你指定的那个profile的样子了。具体方法可以百度:Python selenium profile。别问我为什么知道这些,我刚从坑里爬出来。
我要该,理由是:selenium(16)
本文是对上一节的补充:
使用Selenium2(webdriver)启动firefox且自动加载firebug插件时,切换到firebug插件的网络和cookies部分时,提示面板已被禁用,如下图所示:
于是我们输入about:config在firefox设置页面试着去找下是否有什么参数控制着面板的禁用/启用,果然被我找到如下两个参数:
cookies面板 --- &extensions.firebug.cookies.enableSites网络面板   --- &extensions.firebug.net.enableSites
  firefox设置页面参数非常的多,如果我们不知道某项设置的参数名时,我们可以手工在firefox界面设置参数的值,然后根据我们定制的值去about:config里面找就可以找到,从而找到我们要设置的参数。
在代码中设置这两个参数的值为true,运行结果如下:
代码如下:
public static void StartFireFoxLoadPlugin(){
System.out.println(&start firefox browser...&);
System.setProperty(&webdriver.firefox.bin&,
&D:/Program Files/Mozilla Firefox/firefox.exe&);
File file = new File(&files/firebug-1.9.0-fx.xpi&);
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(file);
} catch (IOException e) {
e.printStackTrace();
//设置firebug版本
profile.setPreference(&extensions.firebug.currentVersion&, &1.9.0&);
//自动打开firebug
profile.setPreference(&extensions.firebug.allPagesActivation&, &on&);
//设置启用firebug网络面板
profile.setPreference(&extensions.firebug.net.enableSites&, true);
//设置启用firebugcookies面板
profile.setPreference(&extensions.firebug.cookies.enableSites&, true);
WebDriver driver = new FirefoxDriver(profile);
driver.get(&&);
System.out.println(&start firefox browser succeed...&);
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:59882次
积分:1017
积分:1017
排名:千里之外
原创:11篇
转载:196篇
(3)(6)(4)(1)(18)(31)(38)(16)(16)(27)(27)(19)(3)
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'}

我要回帖

更多关于 firefox selenium 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信