Selenium(Webdriver)支持Firefox,IE,Chrome等多个浏览器。很多人可能装环境时遇到很多问题,下面简单聊聊如何配置测试这几个浏览器以及相关通过简单的实例来测试。

1.Firefox浏览器

Firefox浏览器是Selenium自动化测试中最常用的一个浏览器,包括Selenium IDE插件,FireBug插件,FirePath插件等自动化测试必备的辅助工具。

而且Firefox驱动包含在Selenium安装包中,无需再下载Firefox驱动,安装完Selenium后就可以直接使用Firefox浏览器了。

前提是,电脑得装有Firefox浏览器。

常见问题:运行脚本没报错,但浏览器始终为空白的,可查看我另外一篇博文:Python+Selenuim测试网站,只能打开Firefox浏览器却不能打开网页的解决方法

脚本如下:

# coding=utf-8
'''
Created on 2016-8-16
@author: Jennifer
Project:使用Firefox浏览器
'''
from selenium import webdriver driver = webdriver.Firefox()
driver.get('http://www.baidu.com')
driver.find_element_by_id('kw').send_keys('Selenium')
driver.find_element_by_id('su').click() driver.quit()

2.IE浏览器

需要下载IEDriverServer.exe,由于国内禁止了http://code.google.com和http://www.seleniumhq.org/download/的软件下载,可以去csdn下载,有很多童鞋共享了软件。

前提是,电脑得装有IE浏览器。

解决方案:

1.将IEDriverServer.exe放在python的安装目录C:\Python27。

注:装python环境时,已经将C:\Python27添加到系统环境变量Path下面了。

 2.关闭IE的启用保护模式

打开IE——》设置——》Internet选项——》安全——》去掉启用保护模式前的对勾

脚本如下:

# coding=utf-8
'''
Created on 2016-8-16
@author: Jennifer
Project:使用ie浏览器,需安装IEDriverServer.exe
'''
from selenium import webdriver driver = webdriver.Ie()
driver.get('http://www.baidu.com')
driver.find_element_by_id('kw').send_keys('Selenium')
driver.find_element_by_id('su').click() driver.quit()

3.Chrome浏览器

需要下载chromedriver.exe,由于国内禁止了http://code.google.com和http://www.seleniumhq.org/download/的软件下载,可以去csdn下载,有很多童鞋共享了软件。

前提是,电脑得装有Chrome浏览器。

解决方案:

将chromedriver.exe放在python的安装目录C:\Python27。

注:装python环境时,已经将C:\Python27添加到系统环境变量Path下面了。

脚本如下:

# coding=utf-8
'''
Created on 2016-8-16
@author: Jennifer
Project:使用chrome浏览器,安装chromewebdriver.exe
'''
from selenium import webdriver driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
driver.find_element_by_id('kw').send_keys('Selenium')
driver.find_element_by_id('su').click() driver.quit()

Python+Selenium 环境配置之Firefox,IE,Chrome几种浏览器运行的更多相关文章

  1. python+selenium环境配置及浏览器调用

    最近在学习python自动化,从项目角度和技术基础角度出发,我选择了python+selenium+appium的模式开始我的自动化测试之旅: 一.python安装 二.python IDE使用简介 ...

  2. python+selenium环境配置(windows7环境)

    下载python[python开发环境] http://python.org/getit/ 下载setuptools[python的基础包工具] http://pypi.python.org/pypi ...

  3. python selenium环境配置Firefox和Chrome

    1.下载Selenium库,可以使用pip install selenium https://pypi.python.org/pypi/selenium/ 2.下载驱动 Chrome: https:/ ...

  4. python+selenium 环境配置

    配置环境: python:3.5 selenium:3.3.0 安装方式:python pip install -u selenium windows: 10 firefox:52 因为firefox ...

  5. Python+selenium 自动化-启用带插件的chrome浏览器,调用浏览器带插件,浏览器加载配置信息。

    Python+selenium 自动化-启用带插件的chrome浏览器,调用浏览器带插件,浏览器加载配置信息.   本文链接:https://blog.csdn.net/qq_38161040/art ...

  6. Linux—CentOS7下python开发环境配置

    CentOS7下python开发环境配置 上一篇博客讲了如何在Centos7下安装python3(https://www.cnblogs.com/zivli/p/9937608.html),这一次配置 ...

  7. python 开发环境配置

    上篇文章配置了虚机基础环境,本篇文章介绍配置python开发环境 配置YUM源 使用国内yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos ...

  8. centos7.0 安装日志--图文具体解释-python开发环境配置

    centos7.0公布之后,就下载了everthing的DVD镜像.今天有时间,所以决定在vbox底下体验一番--- 上图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nk ...

  9. 最简单的VScode Python 开发环境配置以及中文化

    前置条件 Python 3.X(2020年了,建议使用Python3.X版本) 一.下载VSCode VSCode官方下载链接 由于安装过程是中文界面,此处略过. 二.VSCode中文化 不需要配置什 ...

随机推荐

  1. VideoTexture 贴图

    //old bitmapData.lock(); bitmapData.fillRect(_clippingRect, 0); bitmapData.draw(_player.container, n ...

  2. svn revert

    本地开发环境出现一个问题,用revert完美解决. 问题描述: 文件static/image/common/jiqiaodaren.png已经被提交到svn上,但是我的开发环境因未与svn同步,所以没 ...

  3. Hibernate4 占位符(?)

    Hibernate3使用?占位符: Session session = sessionFactory.getCurrentSession();  session.beginTransaction(); ...

  4. parted

    1.选择分区表 sudo parted -s /dev/sdXX mklabel gpt 2.创建分区 sudo parted -s -- /dev/sdX mkpart primary 0 -1s ...

  5. selenium2(WebDriver) API

    selenium2(WebDriver) API 作者:Glen.He出处:http://www.cnblogs.com/puresoul/  1.1  下载selenium2.0的包 官方downl ...

  6. A convenient way of installing(compiling) VIM with YCM

    Ah, while I am still downloading LLVM from github(very slow.. and very large in size). I come with m ...

  7. Java-枚举介绍

    需求:今天遇到一个问题,就是返回某些固定的int值,要用到枚举. 下面开始介绍: 无参构造方法的枚举 enum Color{ YELLOW,BLUE,RED } 解析:首先Color本身是一个枚举,里 ...

  8. [转]Android 如何对sqlite数据库进行增删改[insert、update和delete] 操作

    import android.content.ContentValues; import android.content.Context; import android.database.Cursor ...

  9. const与static的区别

    const就是只读的意思,只在声明中使用;const修饰的数据类型是指常类型,常类型的变量或对象的值是不能被更新的. const的作用: (1)可以定义const常量,具有不可变性. (2)便于进行类 ...

  10. HDU2952:Counting Sheep(DFS)

    Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...