市面上用来做Web自动化的主流工具
1.QTP(收费)
2.Selenium:开源工具
3.Robot Framework:开源框架,基于Python的关键字驱动框架
为什么选择Selenium
1.开源:开放源代码
2.跨平台:Linux,Windows,Mac
3.支持多种浏览器:Chrome,Firefox,IE,Edge,Opera等
4.支持多种语言:Python,Java,C#,C++等
5.成熟稳定:被多家500强公司使用
6.功能强大
安装Selenium
前提:基于Python
1.安装Python环境(python3以上)
2.安装Selenium库 安装:pip install selenium 验证:pip list
3.安装浏览器(推荐Chrome)
4.安装浏览器驱动
①.根据浏览器的版本下载驱动
123之前的驱动:https://chromedriver.storage.googleapis.com/index.html
123之后的驱动:https://googlechromelabs.github.io/chrome-for-testing/#stable
②.将驱动文件添加到环境变量path中 或者跟Python放一起也行,因为Python也配置好了环境变量。
验证代码
import time
from selenium import webdriver
driver=webdriver.Chrome()
driver.get("http://www.baidu.com")
time.sleep(3)
driver.quit()