seleniumRC启动及浏览器实例配置

时间:2022-01-30 21:52:01

一、firefox浏览器实例配置

1、启动用户配置文件管理器

重要:在启动用户配置文件管理器之前,Firefox必须完全关闭。
    1)按 seleniumRC启动及浏览器实例配置seleniumRC启动及浏览器实例配置support.cdn.mozilla.net/media/uploads/gallery/images/2011-09-20-08-33-13-ff63c4.jpg" alt="Windows Key" title="" />+ R(Windows XP 上:点击 Windows 的 开始 按钮,选择 运行...)。
    2)在运行对话框中,输入: firefox.exe -p
就会弹出用户配置文件管理器,如下图:
seleniumRC启动及浏览器实例配置
 说明:
(1)default是本机器安装firefox后,默认的用户配置文件
        比如我的用户配置文件为:C:\Users\用户名\Application Data\Mozilla\Firefox\Profiles\56ktcqhd.default
(2)点击 Create Profile,可以新建自己配置文件, 比如为 跑selenium 脚本,专门配置一个实例
        命名配置文件, 并且选择要放置的位置,比如, 我不放在默认位置, 则ChooseFolder,选择D:\Program Files\selenium\ff-profile
seleniumRC启动及浏览器实例配置
(3)配置完成后, 双击profile,(或者选中,然后点击StartFirefox按钮)浏览器当前就会按照这种配置启动,比如双击 selenium-profile
seleniumRC启动及浏览器实例配置
(4)上述(3)方式启动浏览器后, 下次浏览器就按照这个配置去打开(比如, 在默认的配置下收藏的标签, 在这里就找不到了)
快速切换用户配置方法,可以建 .bat文件 来执行
文件命令内容:
cd C:\Users\用户名\AppData\Local\Mozilla Firefox    //firefox安装位置, 按照实际情况切换
firefox.exe -profile "C:\Users\用户名\Application Data\Mozilla\Firefox\Profiles\56ktcqhd.default" -no-remote
这种方式启动后,再关闭,又回到原来默认配置
所以要修改成默认配置用户文件, 要到 “用户配置文件管理器”里去设置。 
 

firefox配置详见官网地址:http://support.mozilla.org/zh-CN/kb/%E7%AE%A1%E7%90%86%E7%94%A8%E6%88%B7%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6?redirectlocale=en-US&redirectslug=Managing+profiles

二、启动selenium RC

java -jar selenium-server-standalone-2.33.0.jar -port 4444  -firefoxProfileTemplate "path to the profile"

seleniumRC启动及浏览器实例配置

PS:

自定义自己的浏览器配置后, 在selenium2.0中, 采用新的profile方法:

    File filepath=new File("D:\\selenium-profile");
FirefoxProfile profile=new FirefoxProfile(filepath);
WebDriver driver=new FirefoxDriver(profile);