zoukankan      html  css  js  c++  java
  • 加载 Firefox 配置


           有小伙伴在用脚本启动浏览器时候发现原来下载的插件不见了,无法用 firebug在打开的页面上继续定位页面元素,调试起来不方便 。
    加载浏览器配置,需要用 FirefoxProfile(profile_directory)这个类来加载,profile_directory 既为浏览器配置文件的路径地址

    FirefoxProfile

    1.要想了解 selenium 里面 API 的用法,最好先看下相关的帮助文档打开 cmd 窗口,
    输入如下信息:
    -》python
    -》from selenium import webdriver
    -》help(webdriver.FirefoxProfile)

    Help on class FirefoxProfile in module
    selenium.webdriver.firefox.firefox_profile:
    class FirefoxProfile( builtin.object)
    | Methods defined here:
    |
    | init(self, profile_directory=None)
    | Initialises a new instance of a Firefox Profile
    |
    | :args:
    | - profile_directory: Directory of profile that you want to use.
    | This defaults to None and will create a new
    | directory when object is created.

    2.翻译过来大概意思是说,这里需要 profile_directory 这个配置文件路径的参数3.profile_directory=None,如果没有路径,默认为 None,启动的是一个新的,有的话就加载指定的路径

    profile_directory

    1.问题来了:Firefox 的配置文件地址如何找到呢?
    2.打开 Firefox 点右上角设置>帮助>故障排除信息>显示文件夹

    3.打开后把路径复制下来就可以了:
    C:UsersxxxAppDataRoamingMozillaFirefoxProfiles1x41j9of.default

    启动配置文件

    1.由于文件路径存在字符: ,反斜杠在代码里是转义字符
    2.遇到转义字符,为了不让转义,有两种处理方式:
    第一种: (前面再加一个反斜杠)
    第二种:r”"(字符串前面加 r,使用字符串原型)

  • 相关阅读:
    npm常用命令
    关于事件委托和时间冒泡(以及apply和call的事项)
    js 杂记
    angular中关于ng-repeat的性能问题
    关于日期的一些东西
    杂记
    angular中关于自定义指令——repeat渲染完成后执行动作
    angular中事件戳转日期的格式
    ES6-promise
    angular中ng-class的一些用法
  • 原文地址:https://www.cnblogs.com/101718qiong/p/7943129.html
Copyright © 2011-2022 走看看