zoukankan      html  css  js  c++  java
  • Webdriver如何启动不同浏览器(python)

    WebDriver 支持 Firefox (FirefoxDriver)IE (InternetExplorerDriver)Opera (OperaDriver) Chrome (ChromeDriver) 由于国内禁止了http://code.google.comhttp://www.seleniumhq.org/download/的软件下载,可以去csdn下载,有很多童鞋共享了软件。

    一、Firefox
     不需要下载FirefoxDriver,直接编写代码即可
       from selenium import webdriver
       browser = webdriver.Firefox()
       browser.get('https://www.baidu.com/')

    二、IE
       1、下载IEDriverServer.exe(机器安装IE浏览器)

       2IEDriverServer.exe放在python的安装目录C:\Python27python环境时,已经将C:\Python27添加到系统环境变量Path下面了或者放到IE的安装目录下,并将该   目录添加到系统环境变量Path下面;
      如何不添加环境变量,也可以在代码里这样写:

       from selenium import webdriver

       import os

       Iedriver = "C:\Program Files\Internet Explorer\IEDriverServer.exe"

       os.environ["webdriver.chrome.driver"] = Iedriver

       browser = webdriver.Chrome(Iedriver )

       browser.get('https://www.baidu.com/')

    三、Chrome
       1、下载ChromeDriver.exe
       2、将ChromeDriver.exe放在python的安装目录C:\Python27python环境时,已经将C:\Python27添加到系统环境变量Path下面了或者放到chrome的安装目录下,并将   该目录添加到系统环境变量Path下面;
      如何不添加环境变量,也可以在代码里这样写:

       from selenium import webdriver

       import os

       chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"

       os.environ["webdriver.chrome.driver"] = chromedriver

       browser = webdriver.Chrome(chromedriver)

       browser.get('https://www.baidu.com/')

  • 相关阅读:
    javascript实现根据时间段显示问候语的方法
    视觉会议收藏一
    cv的期刊和会议
    CVPR2016 Paper list
    CVPR 2017 Paper list
    关注的牛人
    cvpr2016论文
    linux命令技巧:scp多文件远程拷贝
    linux命令技巧--df -lh:查看磁盘占用情况
    spark--01编译安装spark1.3.1
  • 原文地址:https://www.cnblogs.com/zhaosunwei/p/6804474.html
Copyright © 2011-2022 走看看