def superMember(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
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 message(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
def login(): # # 打开浏览器 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.Click('老白首页', '签到') try: if "请不要重复签到!" in driver.page_source: print("已签到,请不要重复签到") else: print("签到成功") except: pass uihandle.Click('老白首页', '确定') print('关闭签到页面') uihandle.Click('老白首页', '我的老白') time.sleep(3) handles = driver.window_handles print(handles) driver.switch_to_window(handles[1]) # print(driver.page_source) res = driver.page_source title = driver.title img = get_screenshot(driver) a = [res, title, img] # uihandle.quit() # time.sleep(3) driver.switch_to_window(handles[1]) driver.close() print("handles1关闭") return a
def cart(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
def honeycomb(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
def hfcz(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="家庭圈"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [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 homepage(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 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
def other(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
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 login(): # # 打开浏览器 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.Click('老白首页', '隐形眼镜') time.sleep(5) handles = driver.window_handles driver.switch_to.window(handles[1]) # time.sleep(5) # print(driver.current_url, driver.title) res = driver.page_source title = driver.title img = get_screenshot(driver) a = [res, title, img] # uihandle.quit() driver.close() 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 services(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
def todayHotSelling(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://localhost:4723/wd/hub', config()) # 传入driver对象 ui_handle = UIHandle(driver) # driver.implicitly_wait(30) ui_handle.Click('首页-今日热卖', '滚动栏') ui_handle.Click('首页-今日热卖', '滚动栏返回') ui_handle.Click('首页-今日热卖', '签到领钱') ui_handle.Click('首页-今日热卖', '签到页面返回') ui_handle.Click('首页-今日热卖', '热卖榜单') ui_handle.Click('首页-今日热卖', '热卖榜单返回') ui_handle.Click('首页-今日热卖', '升级会员') ui_handle.Click('首页-今日热卖', '升级会员返回') ui_handle.Click('首页-今日热卖', '新人专享') ui_handle.Click('首页-今日热卖', '新人专享返回') ui_handle.Click('首页-今日热卖', '增值服务') ui_handle.Click('首页-今日热卖', '增值服务页面返回') ui_handle.Swipe(500, 1500, 500, 400) ui_handle.Click('首页-今日热卖', '正在疯抢') ui_handle.Click('首页-今日热卖', '商品详情页返回') # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
def mine(): # 调用desired_caps的app配置项 driver = webdriver.Remote('http://*****:*****@text="新增服务号"]').text # 定义截图方法 img = get_screenshot(driver) ui_handle.quit() # 定义数组a,包含name和img a = [img] return a
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
def login(): # # 打开浏览器 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]) time.sleep(3) uihandle.Click('老白首页', '我的订单') handles = driver.window_handles print(handles) driver.switch_to_window(handles[1]) # uihandle.Click('老白首页', '待付款') # time.sleep(3) # # uihandle.Click('老白首页', '待发货') # time.sleep(3) # uihandle.Click('老白首页', '待收货') # time.sleep(3) # uihandle.Click('老白首页', '待评价') # time.sleep(3) # uihandle.Click('老白首页', '信息概要') # time.sleep(3) # # uihandle.Click('老白首页', '我的评价') # time.sleep(3) # # uihandle.Click('老白首页', '我的优惠券') # time.sleep(3) # # uihandle.Click('老白首页', '健康豆兑换优惠券') # time.sleep(3) # # uihandle.Click('老白首页', '免费领取优惠券') # time.sleep(3) # # uihandle.Click('老白首页', '我的健康豆') # time.sleep(3) uihandle.Click('老白首页', '我的余额') time.sleep(3) js = "window.scrollTo(0,500)" driver.execute_script(js) time.sleep(3) uihandle.Click('老白首页', '我的资料') time.sleep(3) js = "window.scrollTo(0,500)" driver.execute_script(js) time.sleep(3) uihandle.Click('老白首页', '修改密码') time.sleep(3) js = "window.scrollTo(0,500)" driver.execute_script(js) time.sleep(3) uihandle.Click('老白首页', '收货地址管理') time.sleep(3) js = "window.scrollTo(0,500)" driver.execute_script(js) time.sleep(3) # 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(handles[1]) driver.close() return a