摘要:def md5(preosign): import hashlib m = hashlib.md5() preosign = preosign.encode('utf-8') m.update(preosign) return m.hexdigest() if __name__ == '__main
阅读全文
摘要:1.由于日期控件输入框是只读属性的如 <input id="txtDate1" class="appinp" type="text" style="width: 100px;" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:
阅读全文
摘要:# 屏幕截图 def save_screen_shot(): picture_name = DirAndTime.create_picture_path() + '\\' + DirAndTime.get_current_time() + '.png' try: driver.get_screens
阅读全文
摘要:#点击元素拖动 def click_move(by,locator,value): try: source = get_element(driver,by,locator) # 需要滑动的元素 action = ActionChains(driver) action.click_and_hold(s
阅读全文
摘要:#清理文件夹 def clear_file(path_data): try: for i in os.listdir(path_data) : # os.listdir(path_data)#返回一个列表,里面是当前目录下面的所有东西的相对路径 file_data = path_data + "\\
阅读全文
摘要:def mysqls_more(sql): # 连接数据库 hostvalue = 'localhost' uservalue = 'root' passwordvalue = 'root' dbvalue = 'book' portvalue = 3306 connection = pymysql
阅读全文
摘要:#excel报告 def Email_excel(data): try: fromaddr = '1836166651@qq.com' password = 'rbekwgamdokabgjh' toaddrs = ['1836166651@qq.com'] #toaddrs = value1 co
阅读全文
摘要:# 获取图片中像素点数量最多的像素 def get_threshold(image): pixel_dict = defaultdict(int) #image = '..\exceptionpictures\%s\%s.png' % (path, img_name) # 像素及该像素出现次数的字典
阅读全文
摘要:''' #移动到绝对位置 js = "window.scrollTo(0,1000);" driver.execute_script(js) sleep(5) #移动到相对位置,移动300,再移动300 js = "window.scrollBy(0,300);" driver.execute_sc
阅读全文
摘要:''' select_by_index() # 通过索引定位-选项 select_by_value() # 通过value值定位-选项 select_by_visible_text() # 通过文本值定位-选项 deselect_all() # 取消所有选项 deselect_by_index()
阅读全文
摘要:''' perform(): 执行所有 ActionChains 中存储的行为; context_click(): 右击; double_click(): 双击; drag_and_drop(): 拖动; move_to_element(): 鼠标悬停 #下面是一些常用的键盘事件: # Keys.B
阅读全文
摘要:# 这是切换到新窗口 def switch_new_window(): try: new_window = driver.window_handles[-1] driver.switch_to.window(new_window) except Exception as e: raise e # 跳
阅读全文
摘要:''' selenium无法直接操作windows窗体,上传控件有属性(type="file")时,可直接sendkeys处理上传文件 WebElement adFileUpload = driver.findElement(By.id(" ###")); // 定位上传控件 String file
阅读全文
摘要:# 打开浏览器并最大化 def open_browser(browser): #无窗口模式 #option = webdriver.ChormeOptions() #option.add_argument('headless') global driver, waitUtil try: if bro
阅读全文
摘要:#将目录下边的所有文件删除,包括文件夹 import os def getAllDir(path): fillAll = os.listdir(path) #print(fillAll) for filename in fillAll: filePath = os.path.join(path,fi
阅读全文