Selenium with Python 001 - 安装篇

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Selenium with Python 001 - 安装篇相关的知识,希望对你有一定的参考价值。

Selenium Python binding提供了简单API来使用Selenium WebDriver编写功能/验收测试。通过Selenium Python API,我们可以直观地访问Selenium WebDriver的所有功能。Selenium Python binding提供了一种方便的API来访问和操作浏览器,如Firefox,Ie,Chrome。目前支持的Python版本是2.7,3.5及更高版本。

 

一、安装python selenium binding

pip install selenium

 

二、安装浏览器驱动

Chrome:https://sites.google.com/a/chromium.org/chromedriver/downloads

Edge:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

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

Safari:https://webkit.org/blog/6900/webdriver-support-in-safari-10/

使用不同的浏览器,需要下载对应驱动,并且确保驱动可执行文件,如chromedriver.exe放到你的系统环境PATH中,这里我将它放到python安装目录下。D:\360YP\VM\Python35\chromedriver.exe

 

三、下载Selenium Server

注意:The Selenium server is only required if you want to use the remote WebDriver

Selenium Server 是个java 程序,推荐使用JRE 1.6以上的java环境运行。我们可以从download page of selenium website 中下载 Selenium Standalone Server,名字类似 selenium-server-standalone-3.5.0.jar,启动方式如

java -jar selenium-server-standalone-3.5.0.jar

使用详情,请查看后面章节介绍。

 

以上是关于Selenium with Python 001 - 安装篇的主要内容,如果未能解决你的问题,请参考以下文章

Selenium with Python中文翻译文档

[Selenium+Java] How to Use Selenium with Python: Complete Tutorial

Selenium with Python 007 - Cookie处理

Selenium with Python 003 - 页面元素定位

Selenium with Python 010 - unittest 框架(又称PyUnit 框架)

Selenium with Python - Chromedriver 必须在 PATH 中