def login(username, password): # 打开浏览器 driver = browser_config['chrome'] # print(driver) # driver.maximize_window() print(driver.get_window_size()) driver.set_window_size(1200, 800) print(driver.get_window_size()) driver.implicitly_wait(30) # 脚本运行时,错误的信息将被打印到这个列表中 driver.verificationErrors = [] # #是否继续接受下一下警告 driver.accept_next_alert = True # 传入driver对象 uihandle = UIHandle(driver) # 输入url地址 uihandle.get(LOGIN_URL) uihandle.Click("老白首页", "首页登录按钮") time.sleep(3) uihandle.Clear('老白首页', '用户名') uihandle.Input('老白首页', '用户名', username) uihandle.Input('老白首页', '密码', password) uihandle.Click('老白首页', '登录页面登录按钮') time.sleep(3) res = driver.page_source title = driver.title img = get_screenshot(driver) a = [res, title, img] return a
def search(msg): # 打开浏览器 driver = browser_config['chrome'] # 传入driver对象 uihandle = UIHandle(driver) # 输入URL地址 uihandle.get(LOGIN_URL) # 调用二次封装后的方法,此处可见操作了哪个页面, # 哪个元素,msg是要插入的值,插入值得操作在另外一个用例文件中传入 uihandle.Input('博客园首页', '找找看输入框', msg) uihandle.Click('博客园首页', '找找看按钮') uihandle.quit()
def login(mobile, code): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text='首页' and contains(@resource-id,'tab')]").text # driver.find_element_by_xpath("//*[@text='体重管理']").click() # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
def search(name): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
13 def search(msg): 14 # 打开浏览器 15 driver = browser_config['chrome']() 16 # 传入driver对象 17 uihandle = UIHandle(driver) 18 #输入url地址 19 uihandle.get(LOGIN_URL) 20 # 调用二次封装后的方法,此处可见操作了哪个页面,哪个元素,msg是要插入的值,插入值得操作在另外一个用例文件中传入 21 uihandle.Input('博客园首页', '找找看输入框', msg) 22 uihandle.Click('博客园首页', '找找看按钮') 23 uihandle.quit() 复制代码 复制代码 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # @Time : 2017-05-17 11:19 4 # log/log.py 5 6 import logging 7 import logging.handlers 8 9 # 日志类
def login(words): # # 打开浏览器 driver = browser_config['chrome'] # driver.maximize_window() # driver.implicitly_wait(30) # # #脚本运行时,错误的信息将被打印到这个列表中 # driver.verificationErrors = [] # # #是否继续接受下一下警告 # driver.accept_next_alert = True # 传入driver对象 uihandle = UIHandle(driver) #输入url地址 # uihandle.get(LOGIN_URL) # driver.find_element_by_link_text(u"登录").click() # time.sleep(3) # # #调用登录方法 # config.login_config.login(driver) # 调用二次封装后的方法,此处可见操作了哪个页面,哪个元素,后面是要插入的值,插入值得操作在另外一个用例文件中传入 handles = driver.window_handles driver.switch_to.window(handles[0]) js = "window.scrollTo(0,800)" driver.execute_script(js) uihandle.Click('老白首页', '个人中心') handles = driver.window_handles # print(handles) driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) time.sleep(3) uihandle.Click('老白首页', '家庭医生') time.sleep(3) uihandle.Click('老白首页', '关闭家庭医生') time.sleep(3) uihandle.Click('老白首页', '老白快报') time.sleep(3) handles = driver.window_handles print(handles) driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) uihandle.Click('老白首页', '常用药') time.sleep(3) handles = driver.window_handles driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) uihandle.Click('老白首页', '极速达') time.sleep(3) handles = driver.window_handles driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) uihandle.Click('老白首页', '隐形眼镜1') time.sleep(3) handles = driver.window_handles driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) # time.sleep(3) uihandle.Click('老白首页', '用户中心') time.sleep(3) handles = driver.window_handles driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) uihandle.Click('老白首页', '我的购物车') time.sleep(3) handles = driver.window_handles driver.switch_to_window(handles[1]) driver.close() driver.switch_to_window(handles[0]) time.sleep(3) uihandle.Click('老白首页', '在线客服') time.sleep(3) uihandle.Input('老白首页', '输入字符', words) time.sleep(3) uihandle.Click('老白首页', '发送字符') time.sleep(3) uihandle.Click('老白首页', '关闭在线客服') time.sleep(3) # print(driver.page_source) res = driver.page_source title = driver.title img = get_screenshot(driver) a = [res, title, img] uihandle.quit() # for i in range(8): # driver.close() return a
def login(search): # # 打开浏览器 driver = browser_config['chrome'] # driver.maximize_window() # driver.implicitly_wait(30) # # #脚本运行时,错误的信息将被打印到这个列表中 # driver.verificationErrors = [] # # #是否继续接受下一下警告 # driver.accept_next_alert = True # 传入driver对象 uihandle = UIHandle(driver) # #输入url地址 # uihandle.get(LOGIN_URL) # driver.find_element_by_link_text(u"登录").click() # time.sleep(3) # # #调用登录方法 # config.login_config.login(driver) # 调用二次封装后的方法,此处可见操作了哪个页面,哪个元素,后面是要插入的值,插入值得操作在另外一个用例文件中传入 handles = driver.window_handles driver.switch_to.window(handles[0]) uihandle.Input('老白首页', '搜索输入框', search) time.sleep(3) uihandle.Click( '老白首页', '搜索按钮', ) time.sleep(3) handles = driver.window_handles print(handles) driver.switch_to_window(handles[1]) uihandle.Click('老白首页', '第一个商品') time.sleep(3) handles1 = driver.window_handles print(handles1) driver.switch_to_window(handles1[2]) uihandle.Click('老白首页', '加入购物车') time.sleep(3) uihandle.Click('老白首页', '去结算') time.sleep(3) js = "window.scrollTo(0,1000)" driver.execute_script(js) uihandle.Click('老白首页', '提交订单') time.sleep(5) # print(driver.page_source) res = driver.page_source title = driver.title img = get_screenshot(driver) a = [res, title, img] # uihandle.quit() driver.switch_to_window(handles1[2]) driver.close() driver.switch_to_window(handles1[1]) driver.close() return a