自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 # python -- 生成指定大小的文件

import osimport randomdef creat_file(fileName,fileSize, fileSuffix):“”"生成一个固定大小的文件:param fileName: 文件名:param filePath: 文件存放路径fileSuffix:文件后缀名:return: 无“”"filePath = ‘C:\Users\Administrator\Desktop\生成指定大小文件\’ + fileName + fileSuffix# 生成固定大小的文件d

2020-08-09 16:36:15 1057

翻译 # python-自动化UI测试之---excel数据驱动

encoding = utf-8from openpyxl import load_workbookclass ParseExcel(object):“”“解析excel数据”""def __init__(self,excelPath,sheetName): # 将要读取的excel数据加载到内存(获取一个工作簿对象) self.wb = load_workbook(excelPath) # 获取一个工作表对象 self.sheet = self.wb.get_sh.

2020-08-02 22:07:18 1024 1

翻译 # python-自动化UI测试之---数据驱动

encoding =utf -8from selenium import webdriverimport unittest, time, osimport logging, tracebackimport ddtfrom selenium.common.exceptions import NoSuchElementException初始化日志对象logging.basicConfig(# 日志级别level=logging.INFO,# 日志格式# 时间、代码所在文件名、代码行号、日志

2020-08-02 19:47:45 392

原创 #使用 python 模块源码包进行安装方法

举例 ddt模块:步骤:1.访问网址:https://pypi.org/2.搜索ddt3.下载压缩包,解压到本地4.CMD切换到当前目录5.输入 python setup.py install

2020-08-02 10:12:51 955

翻译 # python-自动化UI测试之---谷歌浏览器自动下载文件到指定目录

encoding = utf-8from selenium import webdriverimport time, unittestclass TestDownLoad(unittest.TestCase):def setUp(self) -> None:“”“测试谷歌浏览器自动下载”""# 创建谷歌浏览器配置对象chromeOptions = webdriver.ChromeOptions()# 将下载文件保存在E盘的iDownload目录# 如果该文件不存在,自动创建pref

2020-07-29 23:37:48 1153

翻译 # python-自动化UI测试之---异常时进行屏幕截图存放至指定的本地目录

encoding = utf-8import timefrom datetime import datetimedef currentDate():“”"生成年月日字符串:return: 年月日“”"date = time.localtime()today = str(date.tm_year) + ‘-’ + str(date.tm_mon) +’-’+str(date.tm_mday)return todaydef currentTime():“”"生成当前时间字符串:ret

2020-07-29 00:10:50 782

翻译 # python-自动化UI测试之---浏览器中打开新标签页

encoding = utf-8import unittestfrom selenium import webdriverimport timeimport win32api, win32conK_CODE = {‘ctrl’:0x11, ‘t’:0x54, ‘tab’:0x09}按下键盘def keyDown(keyName):win32api.keybd_event(K_CODE[keyName],0,0,0)抬起键盘def keyUP(keyName):win32api.keyb

2020-07-27 22:46:22 1203

翻译 # python-自动化UI测试之-高亮显示正在操作的页面元素

encoding = utf-8import unittestfrom selenium import webdriverimport timedef highLightElement(dr,element):“”"高亮显示页面操作元素:param dr: 浏览器:param element: 页面元素:return: 无“”"dr.execute_script(‘arguments[0].setAttribute(“style”,arguments[1]);’,element,‘b

2020-07-25 21:28:49 476

翻译 # python-自动化UI测试之-操作富文本框

encoding = utf-8from selenium import webdriverimport unittest, time, tracebackfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.common.exceptions import TimeoutExceptio

2020-07-25 20:21:30 527

翻译 # python-自动化UI测试之-生成自动化测试报告

import timefrom autoRanzhi.base.html_test_runner import HtmlTestRunnerfrom autoRanzhi.unit_test.loginTest import Test_loginimport unittestclass RanzhiTestRunner():def run_test(self):# 创建测试套件ts = unittest.TestSuite()ts.addTest(Test_login(‘test_login

2020-07-23 22:45:43 724

翻译 # python-自动化UI测试之-自动上传文件(send_keys)

encoding = utf-8from selenium import webdriverimport unittestimport timeimport tracebackfrom selenium.webdriver.support.ui import WebDriverWaitBy是selenium中内置的一个class,在这个class中有各种方法来定位元素from selenium.webdriver.common.by import Byfrom selenium.webdri

2020-07-22 23:07:25 569

翻译 # python-自动化UI测试之- 登陆功能测试(数据驱动)

def rowToList(row):“”"将excel表的行数据,转换成字符串列表:param row:excel表的行:return:字符串列表“”"case = []for r in row:if r.value == None: # 如果单元格为空case.append(’’)else:case.append(str(r.value))return caseimport osfrom autoRanzhi.page.login import Loginimport

2020-07-21 22:51:57 2515

翻译 # python-自动化UI测试之:自动下载文件

from selenium import webdriverimport unittest, timeclass TestDownload(unittest.TestCase):“”"测试下载文件“”"def setUp(self) -> None: # 实例FirefoxProfile,存放自定义配置 profile = webdriver.FirefoxProfile() # 指定下载路径 profile.set_preference('browser.

2020-07-21 21:38:40 636

翻译 # python-自动化UI测试之:结束windows浏览器进程

from selenium import webdriverimport osimport unittestclass TestBrowser(unittest.TestCase):“”"测试关闭浏览器“”"def test_killBrowserProcess(self):“”"杀死浏览器进程:return: 无返回“”"firefoxDr = webdriver.Chrome()chromeDr = webdriver.Firefox()# ieDr = webdriver.

2020-07-20 22:53:32 618

翻译 # python-自动化UI测试之- 登陆页面封装

import timefrom selenium import webdriverclass Login(object):“”“登陆页面”""def init(self, url):“”"属性初始化:param url: 网址“”"self.url = urldef open_page(self): """打开网页""" self.dr = webdriver.Chrome() self.dr.get(self.url) self.dr.implicitl

2020-07-19 23:07:08 1899

翻译 用python操作mysql

import pymysqlclass CommDB(): """封装一个万能的数据库操作类,可以执行所有的SQL语句""" def __init__(self, host, port, db, user, pwd, charset): self.host = host self.port = port self.db = db self.user =user self.pwd = pwd s.

2020-07-19 15:13:29 105

翻译 # 在Ajax方式产生的浮动框中,选择某个选项

encoding = utf-8import unittestfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysimport timeclass TestAjax(unittest.TestCase):“”“测试Ajax方式产生的浮动框”""def setUp(self) -> None: self.dr = webdriver.Chrome() print('----

2020-07-18 20:24:45 80

翻译 # python-自动化UI测试之- 操作页面滚动条

encoding = utf-8from selenium import webdriverimport unittestimport tracebackimport timeclass TestScrollBar(unittest.TestCase):“”“测试滚动条”""def setUp(self) -> None: self.dr = webdriver.Chrome() print('-------测试用例准备就绪--------')def tearDown

2020-07-18 19:47:10 908

翻译 # python-自动化UI测试之‘操作浏览器的Cookie’

from time import sleepfrom selenium import webdriverdef test_cookie(dr,url):“”"操作cookie值:param dr: 浏览器对象:param url: 网址:return: 无“”"dr.get(url)cookies = dr.get_cookies()for cookie in cookies:print(’%s->-%s->%s->%s->%s’ %(cookie[‘nam

2020-07-18 17:07:49 196

翻译 # python-自动化UI测试之‘回溯’

import tracebacktry:if str(123)>5:passexcept Exception:# 保存在统计目录traceback.print_exc(file=open(‘log.log’,mode=‘a’,encoding=‘utf-8’))# 保存在代码文件夹外面一层的新文件夹traceback.print_exc(file=open(’…\错误日志\log.log’, mode=‘a’, encoding=‘utf-8’))print('这是个没意思的玩笑')

2020-07-18 16:30:23 100

翻译 python-自动化UI测试之‘判断页面元素是否存在’

encoding = utf-8from selenium.common.exceptions import NoSuchElementExceptionfrom selenium import webdriverdr = webdriver.Chrome()def isElementPresent(by,value):“”"判断元素是否存在:param by: 方式:param value: 值:return: True or False“”"try:dr.find_element

2020-07-18 09:35:06 3999

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除