最近一个月以来,我都在紧密学习 WEB UI自动化测试,总觉得应该自己好好整理整理学到的知识点以及遇到的难点.有助于巩固知识.
下面我先介绍整个框架的搭建.只做必要操作的简述,不详细介绍.
学习Python,我们应该先搭建python及集成开发环境,下面我配置的是Anaconda,和安装python其实是一样的,具体看此地址有详细介绍:https://www.cnblogs.com/tq007/p/7281105.html
1.安装Anaconda:
anaconda是python的一个科学计算发行版,内置了数百个python经常会使用的库
2021-01-14 其实没必要安装这么多,按需安装即可,刚开始学习不懂,安装了这个玩意。
国外安装地址:www.continuum.io/downloads
国内安装地址:Mirrors.tuna.tsinghua.edu.cn/anaconda/archive
2.检查是否安装成功: 命令行输入python,安装成功打印如下信息:
C:Usersadministrator>python
Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
3.安装pycharm
这里建议大家到官网下载community版本
2021-01-14 额,这也是刚开始不懂,win10都有自带的VS code ,需要额外的插件,但是是JS 开发的好工具,装一个插件就可以开发python了。
接下来我们安装Selenium
4.安装Selenium-------程序驱动
cmd 执行 pip install selenium
检查selenium是否安装成功,进入python idle环境,执行import selenium 回车 help(selenium) 打印如下信息即安装成功
>>> import selenium
>>> help(selenium)
Help on package selenium:
NAME
selenium
DESCRIPTION
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
PACKAGE CONTENTS
common (package)
webdriver (package)
VERSION
3.141.0
-- More --
5.搭建RobotFrameWork 框架
5.1 安装robotframework
pip install robotframework
5.2 安装robotframework-seleniumlibrary---使用于WEB自动化
pip install robotframework-seleniumlibrary
5.3 pycharm插件安装
File--->Setting--->Plugins--->Browser repositories
6.RIDE
自己看情况,是否安装.可直接用pycharm开发robotframework脚本
安装命令:(ride 安装较慢)
pip install -U wxPython
pip install robotframework-ride
检查安装成功:
安装后打开ride,cmd到python3.7安装目录下找到Sctipts,在Sctipts目录下执行python ride.py
7.浏览器驱动安装
7.1 Chorme驱动安装
google浏览器:chromedriver.storage.googleapis.com/index.html?path=2.38/
注意:不同的浏览器对于不同的webdriver,同一浏览器的不同版本同样与webdriver版本一一对应
配置环境变量:
2021-01-14 额....不喜欢RF框架,转用pytest了。主要是RF如果要开发关键字也是要用python,而且粒度个人不懂得掌握。