Appium Python behave 自动化测试框架搭建(3) - Environment.py

2023-10-22 13:38

本文主要是介绍Appium Python behave 自动化测试框架搭建(3) - Environment.py,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!



https://www.pythonhosted.org/behave/api.html#environment-file-functions

1. 框架结构

You may optionally include some environmental controls (code to run before and after steps, scenarios, features or the whole shooting match).

The minimum requirement for a features directory is:

features/
features/everything.feature
features/steps/
features/steps/steps.py

A more complex directory might look like:

features/
features/signup.feature
features/login.feature
features/account_details.feature
features/environment.py
features/steps/
features/steps/website.py
features/steps/utils.py
 
2.
before_step(context, step), after_step(context, step)
These run before and after every step. The step passed in is an instance of Step.
before_scenario(context, scenario), after_scenario(context, scenario)
These run before and after each scenario is run. The scenario passed in is an instance of Scenario.before_feature(context, feature), after_feature(context, feature)These run before and after each feature file is exercised. The feature passed in is an instance of Feature.
 
before_tag(context, tag), after_tag(context, tag)T
hese run before and after a section tagged with the given name. They are invoked for each tag encountered in the order they’re found in the feature file. See  Controlling Things With Tags. The tag passed in is an instance of Tag and because it’s a subclass of string you can do simple tests like:
# -- ASSUMING: tags @browser.chrome or @browser.any are used.
if tag.startswith("browser."):
browser_type = tag.replace("browser.", "", 1)
if browser_type == "chrome":
context.browser = webdriver.Chrome()
else:
context.browser = webdriver.PlainVanilla()
 
before_all(context), after_all(context)
These run before and after the whole shooting match.
 
3. 代码调用顺序
before_all
for feature in all_features:before_featurefor scenario in feature.scenarios:before_scenariofor step in scenario.steps:before_stepstep.run()after_stepafter_scenarioafter_feature
after_all


这篇关于Appium Python behave 自动化测试框架搭建(3) - Environment.py的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/261776

相关文章

使用Python的requests库调用API接口的详细步骤

《使用Python的requests库调用API接口的详细步骤》使用Python的requests库调用API接口是开发中最常用的方式之一,它简化了HTTP请求的处理流程,以下是详细步骤和实战示例,涵... 目录一、准备工作:安装 requests 库二、基本调用流程(以 RESTful API 为例)1.

Python清空Word段落样式的三种方法

《Python清空Word段落样式的三种方法》:本文主要介绍如何用python-docx库清空Word段落样式,提供三种方法:设置为Normal样式、清除直接格式、创建新Normal样式,注意需重... 目录方法一:直接设置段落样式为"Normal"方法二:清除所有直接格式设置方法三:创建新的Normal样

Python调用LibreOffice处理自动化文档的完整指南

《Python调用LibreOffice处理自动化文档的完整指南》在数字化转型的浪潮中,文档处理自动化已成为提升效率的关键,LibreOffice作为开源办公软件的佼佼者,其命令行功能结合Python... 目录引言一、环境搭建:三步构建自动化基石1. 安装LibreOffice与python2. 验证安装

把Python列表中的元素移动到开头的三种方法

《把Python列表中的元素移动到开头的三种方法》在Python编程中,我们经常需要对列表(list)进行操作,有时,我们希望将列表中的某个元素移动到最前面,使其成为第一项,本文给大家介绍了把Pyth... 目录一、查找删除插入法1. 找到元素的索引2. 移除元素3. 插入到列表开头二、使用列表切片(Lis

Python按照24个实用大方向精选的上千种工具库汇总整理

《Python按照24个实用大方向精选的上千种工具库汇总整理》本文整理了Python生态中近千个库,涵盖数据处理、图像处理、网络开发、Web框架、人工智能、科学计算、GUI工具、测试框架、环境管理等多... 目录1、数据处理文本处理特殊文本处理html/XML 解析文件处理配置文件处理文档相关日志管理日期和

Python标准库datetime模块日期和时间数据类型解读

《Python标准库datetime模块日期和时间数据类型解读》文章介绍Python中datetime模块的date、time、datetime类,用于处理日期、时间及日期时间结合体,通过属性获取时间... 目录Datetime常用类日期date类型使用时间 time 类型使用日期和时间的结合体–日期时间(

使用Python开发一个Ditto剪贴板数据导出工具

《使用Python开发一个Ditto剪贴板数据导出工具》在日常工作中,我们经常需要处理大量的剪贴板数据,下面将介绍如何使用Python的wxPython库开发一个图形化工具,实现从Ditto数据库中读... 目录前言运行结果项目需求分析技术选型核心功能实现1. Ditto数据库结构分析2. 数据库自动定位3

Python yield与yield from的简单使用方式

《Pythonyield与yieldfrom的简单使用方式》生成器通过yield定义,可在处理I/O时暂停执行并返回部分结果,待其他任务完成后继续,yieldfrom用于将一个生成器的值传递给另一... 目录python yield与yield from的使用代码结构总结Python yield与yield

python使用Akshare与Streamlit实现股票估值分析教程(图文代码)

《python使用Akshare与Streamlit实现股票估值分析教程(图文代码)》入职测试中的一道题,要求:从Akshare下载某一个股票近十年的财务报表包括,资产负债表,利润表,现金流量表,保存... 目录一、前言二、核心知识点梳理1、Akshare数据获取2、Pandas数据处理3、Matplotl

Django开发时如何避免频繁发送短信验证码(python图文代码)

《Django开发时如何避免频繁发送短信验证码(python图文代码)》Django开发时,为防止频繁发送验证码,后端需用Redis限制请求频率,结合管道技术提升效率,通过生产者消费者模式解耦业务逻辑... 目录避免频繁发送 验证码1. www.chinasem.cn避免频繁发送 验证码逻辑分析2. 避免频繁