zoukankan      html  css  js  c++  java
  • seleniumRC启动及浏览器实例配置

    一、firefox浏览器实例配置

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

    重要:在启动用户配置文件管理器之前,Firefox必须完全关闭。
        1)按 Windows Key+ R(Windows XP 上:点击 Windows 的 开始 按钮,选择 运行...)。
        2)在运行对话框中,输入: firefox.exe -p
    就会弹出用户配置文件管理器,如下图:
     说明:
    (1)default是本机器安装firefox后,默认的用户配置文件
            比如我的用户配置文件为:C:Users用户名Application DataMozillaFirefoxProfiles56ktcqhd.default
    (2)点击 Create Profile,可以新建自己配置文件, 比如为 跑selenium 脚本,专门配置一个实例
            命名配置文件, 并且选择要放置的位置,比如, 我不放在默认位置, 则ChooseFolder,选择D:Program Filesseleniumff-profile
    (3)配置完成后, 双击profile,(或者选中,然后点击StartFirefox按钮)浏览器当前就会按照这种配置启动,比如双击 selenium-profile
    (4)上述(3)方式启动浏览器后, 下次浏览器就按照这个配置去打开(比如, 在默认的配置下收藏的标签, 在这里就找不到了)
    快速切换用户配置方法,可以建 .bat文件 来执行
    文件命令内容:
    cd C:Users用户名AppDataLocalMozilla Firefox    //firefox安装位置, 按照实际情况切换
    firefox.exe -profile "C:Users用户名Application DataMozillaFirefoxProfiles56ktcqhd.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"

    PS:

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

        File filepath=new File("D:\selenium-profile");
        FirefoxProfile profile=new FirefoxProfile(filepath);
        WebDriver driver=new FirefoxDriver(profile);
  • 相关阅读:
    xml模塊
    xlrd,xlwt模塊
    logging模塊
    正則補充
    Android异步处理一:使用Thread+Handler实现非UI线程更新UI界面
    安卓--子线程和主线程之间的交互实例(时钟)
    Android--全局获取Context的技巧
    Android 广播机制
    android编写Service入门
    Android的Looper,Handler以及线程间的通信
  • 原文地址:https://www.cnblogs.com/jenniferhuang/p/3429095.html
Copyright © 2011-2022 走看看