python自动化
黑夜里的月亮
千里之行 始于足下
展开
-
selenium动态元素定位
selenium动态元素定位在web自动化中,存在很多动态元素,各种新增表单,删除表单,编辑表单等类似的功能,都有可能导致其id,class等属性会发生变化,我们可以通过属性的一部分固定内容来进行定位,如:通过xpath来定位 drive.find_element_by_xpath("//iframe[starts-with(@attribute,'content')]") attribute是不变的元素属性 ,content则是属性的内容 这里采用以什么开头如定位一个属性为 href ,定位原创 2021-08-06 12:03:13 · 2885 阅读 · 0 评论 -
airtest使用常见问题(mac系统)
1. pycharm中安装 airtest 模块失败解决方法:不使用pycharm安装,利用终端进行安装,同时本机需要安装pythonpython下载安装安装:https://www.python.org/downloads/mac-osx/mac系统Python环境变量配置,open ~/.zchrcmac系统中一般python路径(根据下载的Python版本进行调整)#Setting PATH for Python 3.7export PATH=${PATH}:/Library/Fra原创 2021-07-28 17:47:27 · 1616 阅读 · 0 评论 -
selenium自动化常见问题
常见问题只清除缓存如:cookies = driver.get_cookies()print(f"cookies = {cookies}")driver.delete_all_cookies()原创 2021-07-16 09:43:29 · 110 阅读 · 0 评论 -
Airtest/appium使用(MAC系统)
Airtest/appium使用(MAC系统)appium:环境配置:统一:安装python3、安装Airtest/appniumAndroid:安装:java、sdk(下载安装android studio(主用于下载sdk,运行模拟器))mac环境变量配置(python,sdk,java):终端运行:sudo tuoch ~/.zshrcopen ~/.zshrc写入:export ANDROID_HOME=/Users/edz/Library/Android/sdkexpor原创 2021-07-09 17:44:26 · 4658 阅读 · 2 评论 -
Python-配置文件读取
配置文件读取: config.iniconfig.ini 文件configparser模块安装: pip install configparser读取配置文件中的sectionimport configparserimport osimport sys#获取当前目录Baespath = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]#将当前目录放入环境变量中sys.path.append(Baespath)原创 2021-05-14 10:54:46 · 154 阅读 · 0 评论 -
python+selenium自动化测试基本框架-学习笔记
一、框架结构介绍注意:在第一层文件目录中,需要手动创建__init__.py文件① common为公共模块② data:存放数据(如excel,数据库等)③ FindPage:查找页面元素④ run:运行测试脚本⑤ testCase:存放测试用例⑥ testRessult:最后出入的html文件格式的测试报告二、公共模块commoncommon.pyfrom selenium import webdriverimport loggingimport osimport sysB原创 2020-08-28 14:25:56 · 1005 阅读 · 0 评论 -
python读取excel表,xlrd模块
一、安装xlrd模块pip install xlrd如图已有的 testtable.xlsx 文件二、实例import xlrdimport timefrom datetime import datetime,dateimport os#获取当前目录basepath = os.path.dirname(__file__)filenames = basepath + '\\testtable.xlsx'#打开Exccel文件读取数据workbook = xlrd.open_wo原创 2020-08-27 17:03:18 · 284 阅读 · 0 评论 -
python自动化中使用unittestreport输出测试报告
一、安装unittestreportpip install unittestreport具体使用方法:https://github.com/musen123/UnitTestReport二、 具体实例参考用法1 #coding:utf-82 import unittest3 from unittestreport import TestRunner4 import os5 class Counter(unittest.TestCase):67 def setUp(self):8原创 2020-08-21 13:35:16 · 2365 阅读 · 2 评论