摘要: 1、上传 学习链接: https://www.cnblogs.com/yoyoketang/p/6445270.html input标签可以借助send_keys()操作来实现文件上传 <<input type="file" name="file" style="position: absolute 阅读全文
posted @ 2020-05-07 16:50 Penny悦 阅读(193) 评论(0) 推荐(0) 编辑
摘要: webdriver操作cookie的方法如下: get_cookies() get_cookie(name) add_cookie(cookie_dict) delete_cookie(name,optionsString) delete_cookies() 参考代码: from selenium 阅读全文
posted @ 2020-05-06 16:00 Penny悦 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 1、文件目录 在test02.py文件中调用test01.py文件中的ceshi()函数 2、参考代码: test01: def ceshi(): from selenium import webdriver option = webdriver.ChromeOptions() option.add 阅读全文
posted @ 2020-05-06 14:32 Penny悦 阅读(1425) 评论(0) 推荐(0) 编辑
摘要: 1、启动浏览器的时候不想看的浏览器运行,那就加载浏览器的静默模式,让它在后台偷偷运行。 option = webdriver.ChromeOptions()option.add_argument('headless') 2、参考代码: from selenium import webdriver o 阅读全文
posted @ 2020-05-06 11:23 Penny悦 阅读(1007) 评论(0) 推荐(0) 编辑
摘要: print的作用是将输出结果打印到屏幕上 return 的作用是不在屏幕上显示,但会给调用者一个返回值 返回值:所谓的返回值就是程序中的函数在完成一件事情后,最终给调用者的结果。 没有return 语句 没有return语句,所以没能给函数add()赋值,打印出来也就是空值(None) 有retur 阅读全文
posted @ 2020-04-29 17:35 Penny悦 阅读(540) 评论(0) 推荐(0) 编辑
摘要: 操作mysql:需要导入pymysql模块 参考代码: import pymysql# 打开数据库连接db = pymysql.connect('123.123.0.126','root','root','fdgfd')# 使用cursor()方法创建一个游标对象 cursorcursor = db 阅读全文
posted @ 2020-04-20 14:37 Penny悦 阅读(1007) 评论(0) 推荐(0) 编辑
摘要: 1、报告名称加时间戳:引入datetime模块 2、获取目录下的所有文件及文件夹 3、文件及文件夹按时间排序 4、用join连接最新报告路径 参考代码: import unittest import HTMLTestRunner import yagmail import os import dat 阅读全文
posted @ 2020-04-16 13:14 Penny悦 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1、源代码: import csv filepath = r"C:\\Users\\yl8\\Desktop\\user1.csv" csv_file = csv.reader(open(filepath ,"r")) for user1 in csv_file: print(user1[1]) 报 阅读全文
posted @ 2020-04-10 13:01 Penny悦 阅读(2378) 评论(0) 推荐(0) 编辑
摘要: 1、按顺序执行 from selenium import webdriver import unittest import time class BaiduTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.driver = 阅读全文
posted @ 2020-04-10 12:53 Penny悦 阅读(372) 评论(0) 推荐(0) 编辑
摘要: python操作excel使用xlrd、xlwt模块,xlrd模块是读取excel的,xlwt模块是写excel的。这几个模块可以使用pip安装, pip install xlrd pip install xlwt 1、参考代码: # import xlrd import xlwt # file_p 阅读全文
posted @ 2020-04-10 12:29 Penny悦 阅读(468) 评论(0) 推荐(0) 编辑