御命丹心

萧瑟悲声秋风起,刹忆寒蝉未鸣时

导航

随笔分类 -  Python_常用封装

封装方法
MD5自定义加密
摘要:def md5(preosign): import hashlib m = hashlib.md5() preosign = preosign.encode('utf-8') m.update(preosign) return m.hexdigest() if __name__ == '__main 阅读全文

posted @ 2020-07-10 20:11 正法 阅读(270) 评论(0) 推荐(0)

日历框处理
摘要:1.由于日期控件输入框是只读属性的如 <input id="txtDate1" class="appinp" type="text" style="width: 100px;" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH: 阅读全文

posted @ 2020-07-10 20:09 正法 阅读(192) 评论(0) 推荐(0)

截图处理
摘要:# 屏幕截图 def save_screen_shot(): picture_name = DirAndTime.create_picture_path() + '\\' + DirAndTime.get_current_time() + '.png' try: driver.get_screens 阅读全文

posted @ 2020-07-10 19:38 正法 阅读(133) 评论(0) 推荐(0)

滑动处理
摘要:#点击元素拖动 def click_move(by,locator,value): try: source = get_element(driver,by,locator) # 需要滑动的元素 action = ActionChains(driver) action.click_and_hold(s 阅读全文

posted @ 2020-07-10 19:37 正法 阅读(177) 评论(0) 推荐(0)

定时处理
摘要:#清理文件夹 def clear_file(path_data): try: for i in os.listdir(path_data) : # os.listdir(path_data)#返回一个列表,里面是当前目录下面的所有东西的相对路径 file_data = path_data + "\\ 阅读全文

posted @ 2020-07-10 19:35 正法 阅读(109) 评论(0) 推荐(0)

sql处理
摘要:def mysqls_more(sql): # 连接数据库 hostvalue = 'localhost' uservalue = 'root' passwordvalue = 'root' dbvalue = 'book' portvalue = 3306 connection = pymysql 阅读全文

posted @ 2020-07-10 19:34 正法 阅读(198) 评论(0) 推荐(0)

邮箱处理
摘要:#excel报告 def Email_excel(data): try: fromaddr = '1836166651@qq.com' password = 'rbekwgamdokabgjh' toaddrs = ['1836166651@qq.com'] #toaddrs = value1 co 阅读全文

posted @ 2020-07-10 19:33 正法 阅读(145) 评论(0) 推荐(0)

图片识别
摘要:# 获取图片中像素点数量最多的像素 def get_threshold(image): pixel_dict = defaultdict(int) #image = '..\exceptionpictures\%s\%s.png' % (path, img_name) # 像素及该像素出现次数的字典 阅读全文

posted @ 2020-07-10 19:32 正法 阅读(377) 评论(0) 推荐(0)

窗口滑动
摘要:''' #移动到绝对位置 js = "window.scrollTo(0,1000);" driver.execute_script(js) sleep(5) #移动到相对位置,移动300,再移动300 js = "window.scrollBy(0,300);" driver.execute_sc 阅读全文

posted @ 2020-07-10 19:30 正法 阅读(152) 评论(0) 推荐(0)

弹窗处理
摘要:''' select_by_index() # 通过索引定位-选项 select_by_value() # 通过value值定位-选项 select_by_visible_text() # 通过文本值定位-选项 deselect_all() # 取消所有选项 deselect_by_index() 阅读全文

posted @ 2020-07-10 19:28 正法 阅读(161) 评论(0) 推荐(0)

模拟键盘
摘要:''' perform(): 执行所有 ActionChains 中存储的行为; context_click(): 右击; double_click(): 双击; drag_and_drop(): 拖动; move_to_element(): 鼠标悬停 #下面是一些常用的键盘事件: # Keys.B 阅读全文

posted @ 2020-07-10 19:27 正法 阅读(350) 评论(0) 推荐(0)

切换窗口
摘要:# 这是切换到新窗口 def switch_new_window(): try: new_window = driver.window_handles[-1] driver.switch_to.window(new_window) except Exception as e: raise e # 跳 阅读全文

posted @ 2020-07-10 19:25 正法 阅读(125) 评论(0) 推荐(0)

上传控件
摘要:''' selenium无法直接操作windows窗体,上传控件有属性(type="file")时,可直接sendkeys处理上传文件 WebElement adFileUpload = driver.findElement(By.id(" ###")); // 定位上传控件 String file 阅读全文

posted @ 2020-07-10 19:23 正法 阅读(181) 评论(0) 推荐(0)

浏览器驱动
摘要:# 打开浏览器并最大化 def open_browser(browser): #无窗口模式 #option = webdriver.ChormeOptions() #option.add_argument('headless') global driver, waitUtil try: if bro 阅读全文

posted @ 2020-07-10 19:22 正法 阅读(407) 评论(0) 推荐(0)

递归删除目录下所有文件
摘要:#将目录下边的所有文件删除,包括文件夹 import os def getAllDir(path): fillAll = os.listdir(path) #print(fillAll) for filename in fillAll: filePath = os.path.join(path,fi 阅读全文

posted @ 2020-07-10 17:30 正法 阅读(288) 评论(0) 推荐(0)