自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 locust基本使用demo

locust基本使用的demo

2022-10-07 17:25:56 368

原创 Flask框架--用户管理系统实例

from flask import Flask,render_template,request,redirect,sessionapp=Flask(__name__)#一个Flask类的对象app.secret_key="djskhhujas2jdhku33"app.debug=True#自动重启USER_DICT={ '1':{'name':"jelena1","age":18}, '2':{'name':"zhangsan","age":32}, '3':{'name.

2021-01-16 14:18:26 842

原创 selenium--显示等待与元素定位,元素判断等方法结合,源码二次开发

from selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECfrom selenium import webdriverclass Base(): def __init__(self,driver): se.

2021-01-03 21:12:10 333

原创 selenium--窗口切换

from selenium import webdriverimport timedriver=webdriver.Chrome()driver.get("https://www.baidu.com/")time.sleep(2)handle1=driver.current_window_handleprint(handle1)driver.find_element_by_link_text("新闻").click()handles=driver.window_handlesprint(.

2021-01-01 19:38:50 167

原创 selenium元素定位--鼠标事件

百度首页搜索为例from selenium import webdriverimport timefrom selenium.webdriver.common.action_chains import ActionChainsdriver=webdriver.Chrome()driver.get("https://www.baidu.com/")driver.maximize_window()time.sleep(3)#driver.find_element_by_id("kw").se

2021-01-01 17:26:55 249

原创 python--sign签名

import hashlibdef sign_up(body,apikey="12345678"): apikey="12345678" # body={ # "username":"test", # "password":"123456", # "mail":"", # "sign":"签名后的值" # } a=["".join(i) for i in body.items() if i[1] and .

2020-11-03 21:06:37 424

原创 python接口自动化-token登陆

背景:有短信验证码,先获取短信验证码再发POST请求登陆代码:import requestsimport re,jsonimport urllib3requests.packages.urllib3.disable_warnings()sms_url="xxxxxx"headers={xxxx}pars={"mobile":"xxxx"}r=requests.get(sms_url,headers=headers,params=pars,verify=False)pri

2020-09-27 16:18:28 421

原创 python学习--装饰器

user,passwd="jelena","123"def auth(auth_type): print("auth func:",auth_type) def outer_wrapper(func): def wrapper(*args, **kwargs): print("wrapper func:", *args, **kwargs) if auth_type =="local": ..

2020-08-30 20:16:20 124

原创 unittest批量执行测试用例

import unittestdef all_case(): case_dir="case路径" testcase =unittest.TestSuite() discover=unittest.defaultTestLoader.discover(case_dir,pattern="test*.py",top_level_dir=None) for test_suite in discover: for t.

2020-06-24 15:23:30 633

原创 python接口测试登陆jenkins代码

#coding:utf-8import requestsimport reurl="http://localhost:8080/j_acegi_security_check"headers={"Connection": "keep-alive","Content-Length": "xx","Cache-Control": "xx","Origin": "http://localhost:8000","Upgrade-Insecure-Requests":"xx" ,"Content.

2020-06-24 10:36:29 363

原创 requests库学习--post请求

示例相应的接口文档:https://developer.github.com/v3/users/emails/python代码:import requeststest_url = 'https://api.github.com'def get_url(url): return '/'.join([test_url, url])email = ['2474122448@qq.com', 'kwael_xu@163.com']def add_email(): .

2020-06-12 10:28:25 229

原创 requests库学习--http基本认证

import requestsimport base64test_url = 'https://api.github.com'def get_url(url): return '/'.join([test_url, url])def get_user(): r = requests.get(get_url('user'), auth=('uername', 'password')) print(r.status_code) print(r.text) .

2020-06-11 14:47:07 223

原创 selenium自动化--uniitest测试框架之编写日志与浏览器封装类

1.建立目录结构:2.config.ini文件:[browserType]browserName= Chrome[testServer]URL = https://www.baidu.com3.baidu_engine文件,浏览器引擎类封装:# -*- coding:utf-8 -*-import configparserimport os.pathfrom selenium import webdriverfrom framework.logger import

2020-06-09 15:42:05 349

原创 selenium自动化--截图封装

先将基本方法封装写进basepage.py文件中# coding=utf-8import osimport timefrom unittest_demo.logger import Loggermylog = Logger(logger='BasePage').getlog()class BasePage(object): """ 主要是把常用的几个Selenium方法封装到BasePage这个类,我们这里演示以下几个方法 back() forward

2020-06-09 10:37:35 630

转载 selenium自动化--日志打印封装模块

编写logger模块:# _*_ coding: utf-8 _*_import loggingimport os.pathimport timeimport osimport sysclass Logger(object): def __init__(self, logger): """ 指定保存日志的文件路径,日志级别,以及调用文件 将日志存入到指定的文件中 :param logger:

2020-06-05 18:12:18 512

原创 selenium自动化Day5--多窗口之间切换

代码段:# coding=utf-8import seleniumimport timefrom selenium import webdriverfrom selenium.webdriver import ActionChainsfrom selenium.webdriver.common.keys import Keyschrome_driver="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"

2020-06-05 11:09:54 170

原创 selenium自动化Day 5--获取句柄进行页面切换

# coding=utf-8import seleniumimport timefrom selenium import webdriverchrome_driver="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"browser=webdriver.Chrome(executable_path=chrome_driver)browser = webdriver.Chrome()url = "http.

2020-06-01 17:56:14 356

原创 selenium自动化实践Day4--断言页面标题

# coding=utf-8import timefrom selenium import webdriverimport seleniumchrome_driver="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"driver=webdriver.Chrome(executable_path=chrome_driver)driver.maximize_window()driver.get('htt.

2020-05-27 16:30:49 258

原创 selenium自动化实践Day3--获取页面邮箱

import rechrome_driver="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"driver=webdriver.Chrome(executable_path=chrome_driver)driver.maximize_window()driver.implicitly_wait(1)driver.get("http://home.baidu.com/contact.html")# 得到页.

2020-05-27 16:10:00 319

原创 seleniumz自动化实践Day1--第一个自动化脚本【百度搜索selenium,有断言】

实现方法一# coding=utf-8import timefrom selenium import webdriverchrome_driver="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"driver=webdriver.Chrome(executable_path=chrome_driver)driver.maximize_window() # 最大化浏览器窗口driver.implici

2020-05-27 15:44:31 287

原创 seleniumz自动化实践Day1-第一个打开关闭浏览器脚本

import seleniumfrom selenium import webdriver # 导入webdriver包chrome_driver="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"driver=webdriver.Chrome(executable_path=chrome_driver)driver.maximize_window() # 最大化浏览器driver.get("https.

2020-05-25 14:34:40 166

原创 postman--断言

接口文档:https://www.v2ex.com/p/7v9TEc53url:https://www.v2ex.com/api/topics/hot.json代码:tests["状态码必须是200"] = responseCode.code === 200;var res = JSON.parse(responBody);console.log(res.length);test...

2018-09-02 20:31:20 297

原创 postman学习-http请求

Http请求是服务器和客户端之间交换数据的方式。有两种类型的消息:请求--由客户端发送用来触发一个服务器上的动作响应--来自服务器的应答 请求的构成:起始行,Headers,Body...

2018-09-02 20:28:42 196

原创 appium之启动app

先贴代码:# coding:utf-8import osfrom appium import webdriverapk_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) # 获取当前项目的根路径desired_caps = {}desired_caps['platformName'] =...

2018-08-27 20:59:03 726

原创 selenium自动化-获取元素的属性

# coding:utf-8from selenium import webdriverimport timedriver = webdriver.Chrome()driver.implicitly_wait(10)driver.get("http://www.baidu.com")time.sleep(2)title = driver.titleprint(title)tex...

2018-07-28 16:46:30 3751

原创 selenium自动化-多窗口handle处理

# coding:utf-8from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.support.select import Selectimport timedriver = webdriver.Chr...

2018-07-28 16:41:48 685

原创 selenium自动化-同一个窗口打开网页,只适用于有这个target="_blank"属性链接情况

# coding:utf-8from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.support.select import Selectimport timedriver = webdriver.Chr...

2018-07-28 16:00:27 2245

原创 selenium自动化-js处理内嵌div滚动条

页面源码如下:(copy下来,用文本保存下来,后缀改成.html,用浏览器打开)<!DOCTYPE html><meta charset="UTF-8"> <!-- for HTML5 --><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

2018-07-28 15:35:24 1647

原创 selenium-日历输入框(修改readonly属性)

# coding:utf-8from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.support.select import Selectdriver = webdriver.Chrome()import ...

2018-07-28 15:06:10 3331 1

原创 selenium自动化-select下拉框

方法一:二次定位#coding:utf-8from selenium import webdriverimport randomimport timefrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.action_chains import ActionChainsdrive...

2018-07-28 14:38:30 1065

原创 selenium自动化-#iframe切换

#登录163邮箱代码#coding:utf-8from selenium import webdriverimport randomimport timefrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.action_chains import ActionChainsdri...

2018-07-28 11:23:31 517

原创 selenium自动化-多窗口、句柄(handle)

#coding:utf-8from selenium import webdriverimport randomimport timefrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.action_chains import ActionChainsdriver = webdri...

2018-07-28 10:54:03 520

原创 带参数的装饰器

代码:import timedef timer(func): #timer(test1) func=test1 def deco(*args,**kwargs): start_time=time.time() func(*args,**kwargs) end_time=time.time() print("the f...

2018-07-19 20:32:18 253

原创 简单装饰器

代码实现:import timedef timer(func): #timer(test1) func=test1 def deco(): start_time=time.time() func() end_time=time.time() print("the fun run time is %s"%(end_ti...

2018-07-19 20:09:43 302

转载 简单递归

#coding:utf-8def calc(n): print(n) if int(n/2)>0: return calc(int(n/2)) print("->",n)calc(10)结果:C:\Users\jelena.zhao\AppData\Local\Programs\Python\Python36\python3.exe E:/p...

2018-07-12 19:59:24 180

转载 selenium入门-简单脚本PythonOrgSearch

import unittestfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysclass PythonOrgSearch(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome()...

2018-07-12 18:44:45 265

原创 函数学习:局部变量

#coding:utf-8school="oldboy" #全局变量def change_name(name): global school# 在函数中定义全局变量 school="Mage linux" print("before change",name,school) name="Alex li" #局部变量,只在函数内生效,这个函数就是这个变量的作用...

2018-07-11 20:56:41 211

原创 函数学习:形参跟实参

1.关键字参数不能写在位置参数前面2.默认参数:特点:调用函数时,默认参数可有可无3.参数组参数实际参数不固定:形参以*开头即可 eg:*args接受N个位置参数,转换成元组的形式#coding:utf-8def test(*a): print(a)test(1,2)与位置参数结合:def test1(x,*args): print(x) print(args) ...

2018-07-11 20:42:05 228

原创 python学习--文件操作

高效读文件:f = open("ys",'r',encoding='utf-8')count =0for line in f: if count == 9: print("------woshi---") count += 1 continue print(line.strip()) count += 1文件读写光标移动:...

2018-06-30 16:18:43 161

原创 购物车练习

题目:1.启动程序后,让用户输入工资,然后打印商品列表2.允许用户根据商品编号购买商品3.用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒4.可随时退出,退出时,打印已购买的商品和余额代码:#!/usr/bin/pythonproduct_list=[ ('Iphone',5800), ("Mac Pro",9800), ('Bike',800), ('...

2018-05-11 20:53:43 301

空空如也

空空如也

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

TA关注的人

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