zoukankan      html  css  js  c++  java
  • selenium基础1--环境配置

    什么是webdriver?

       web自动化工具,提供了一套操作浏览器的方法(api应用编程接口说明)

      翻译文档:https://testerhome.com/topics/3222

      官方文档:https://www.selenium.dev/documentation/en/getting_started/

    python中如何安装selenium以及浏览器驱动?

    1、配置python环境,安装selenium(pip install selenium==xxx)

    2、配置浏览器及浏览器驱动(给驱动配置环境变量),注意selenium3.0以上使用Firefox V48以下版本,运行时会报错!

      Firefox V48以上  selenium 3.x

      Firefox V48以下  selenium 2.x

    3、浏览器关闭自动更新,设置禁止安全警告弹窗等:

    (1)Chrome

    • 谷歌浏览器各版本下载地址:

      https://www.portablesoft.org/google-chrome-legacy-versions/
      https://www.chromedownloads.net/

    • chromedriver 下载

      http://chromedriver.storage.googleapis.com/index.html

       

    • 关闭浏览器自动更新

      win + R >> 输入services.msc >> 找到如下 Goolge 更新服务,禁用掉服务

    • 调用 webdriver.Chrome() 

      from selenium import webdriver
      d = webdriver.Chrome()
      d.get('https://www.baidu.com')
      print(d.title)

    (2)Firefox

    • firefox_geckodriver 下载并配置环境变量

      https://github.com/mozilla/geckodriver/releases

    • 浏览器下载地址

      https://download-installer.cdn.mozilla.net/pub/firefox/releases/

    • 设置不检查更新

    • 示例:

      from selenium import webdriver
      d = webdriver.Firefox()
      d.get('https://www.baidu.com')
      print(d.title)

    (3)IE

    • IE 驱动(IE驱动要与selenium版本一致)

      http://selenium-release.storage.googleapis.com/index.html

    • IE 浏览器设置

      Internet选项->安全; 把每个的安全界面的启用保护模式设置为相同(要么全启用,要么全都不启用)

    https://github.com/mozilla/geckodriver/releases

    喜时之言,多失信;怒时之言,多失体
  • 相关阅读:
    HDU4714+三分
    HDU1465+递推
    HDU1437+模拟
    HDU1796+容斥原理
    HDU1432+几何
    Linux---Ls命令 初级实现
    HDU1411+四面体的体积
    HDU1412
    HDU1431+简单题
    请定义一个交通工具(Vehicle)的类,其中有: 属性:速度(speed),体积(size)等等
  • 原文地址:https://www.cnblogs.com/xiaohuboke/p/11268332.html
Copyright © 2011-2022 走看看