Selenium源码学习

1 existing_ld_lib_path = os.environ.get('LD_LIBRARY_PATH', '')

该语句是将名为LD_LIBRARY_PATH的环境变量赋予existing_ld_lib_path

2 shutil.copy(os.path.join(os.path.dirname(__file__), path,self.NO_FOCUS_LIBRARY_NAME), library_path)

将 library_path中的文件复制到os.path.dirname(__file__), path,self.NO_FOCUS_LIBRARY_NAME)中的文件去。

3 key = OpenKey(HKEY_LOCAL_MACHINE, path)

打开注册表中特定KEY 该方法用于注册表寻找程序

4 self.process = Popen( command, stdout=self._log_file, stderr=STDOUT, env=self._firefox_env)

下面是Selemium启动firefox的源码,有时间补上注释

import os
import platform
from subprocess import Popen, STDOUT
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common import utils
import time


class FirefoxBinary(object):

    NO_FOCUS_LIBRARY_NAME = "x_ignore_nofocus.so"

    def __init__(self, firefox_path=None, log_file=None):
        """
        Creates a new instance of Firefox binary.

        :Args:
         - firefox_path - Path to the Firefox executable. By default, it will be detected from the standard locations.
         - log_file - A file object to redirect the firefox process output to. It can be sys.stdout.
                      Please note that with parallel run the output won't be synchronous.
                      By default, it will be redirected to /dev/null.
        """
        self._start_cmd = firefox_path
        # We used to default to subprocess.PIPE instead of /dev/null, but after
        # a while the pipe would fill up and Firefox would freeze.
        self._log_file = log_file or open(os.devnull, "wb")
        self.command_line = None
        if self._start_cmd is None:
            self._start_cmd =
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值