def test_address_new(self, obj): # 进入主界面,通掉用page_home里的页面动作 Page().init_page_home.into_page() # 点击我,通过掉用page_myself里的页面动作 self.use_myself = Page().init_page_myself self.use_myself.click_myself() # 判断用户是否登录 通过掉用page_myself里的页面动作 if not self.use_myself.is_login(): self.use_myself.click_exist_num() self.use_myself.input_num(18610453007) self.use_myself.input_pwd(123456) self.use_myself.click_login() # 点击设置 通过掉用page_myself里的页面动作 self.use_myself.click_setting() # 点击地址管理 self.action.click_address_manage() # 点击 新增地址 self.action.click_new_address() # 输入收件人 self.action.input_receipt(obj[0]) # 输入手机号 self.action.input_phone_num(obj[1]) # 展开省市区下拉 self.action.click_area_select() # 选择省市区 self.action.select_area(obj[2], obj[3], obj[4]) # 输入详细地址 self.action.input_detail_address(obj[5]) # 点击保存 self.action.click_save() time.sleep(2) # 断言 self.action.assert_address_add(obj[0], obj[1])
def test_address_del(self): # 进入主界面 Page().init_page_home.into_page() # 点击我 Page().init_page_myself.click_myself() # 判断用户是否登录 if not Page().init_page_myself.is_login(): Page().init_page_myself.click_exist_num() Page().init_page_myself.input_num(18610453007) Page().init_page_myself.input_pwd(123456) Page().init_page_myself.click_login() # 点击设置 self.action.click_setting() # 点击地址管理 self.action.click_address_manage() time.sleep(1) # 获取删除前的地址条数 before_del = self.action.get_address_count() if not before_del: return else: # 点击编辑 self.action.click_address_edit() # 点击删除 self.action.click_address_del() # 点击确定 self.action.click_address_confirm() time.sleep(1) # 获取删除后的地址条数 after_del = self.action.get_address_count() # 断言 assert before_del - after_del == 1
def test_login_no_num(self, obj): Page().init_page_home.into_page() # 在这里为了避免被操作的元素还未出现,可以设置强制等待,让主界面内容进行加载渲染 time.sleep(2) # 点击 我 self.action.click_myself() # 点击使用已有账号登录 self.action.click_exist_num() # 输入账号 self.action.input_num(obj[0]) # 输入密码 self.action.input_pwd(obj[1]) # 点击登录 self.action.click_login() # 断言账号不存在用例执行是否通过 self.action.assert_toast("此用户不存在")
def setup_class(self): self.page_obj = Page( get_driver('com.yunmall.lc', 'com.yunmall.ymctoc.ui.activity.MainActivity'))
def setup_class(self): # 实例化统一入口类 self.page_obj = Page(init_driver())
def setup_class(self): # 实例化统一入口类 self.page_obj = Page(get_driver("com.yunmall.lc","com.yunmall.ymctoc.ui.activity.MainActivity"))
from selenium.webdriver.common.by import By from Base.get_driver import get_phone_driver from Page.page import Page # 实例化driver driver = get_phone_driver("com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity") # 实例化统一入口类 page_obj = Page(driver) # 点击首页 page_obj.get_homepage().click_my_btn() # 点击注册页面已有账号登录 page_obj.get_signpage().click_sign() # 执行登录操作 # page_obj.get_loginpage().login('13488834010','159357li') """逆向用例获取""" page_obj.get_loginpage().login('13488834010', '15935') # 获取提示消息 # 获取错误提示xpath error_message = (By.XPATH, '//*[contains(@text,"错误")]') massage = page_obj.get_settingpage().get_element(error_message, timeout=5, poll_frequency=0.5).text print(massage) # 获取我的优惠券 # print("获取结果:{}".format(page_obj.get_personpage().get_shop_cart())) # # 点击设置按钮
def setup_class(self): self.driver = init_driver.init_driver() self.search_obj = Page(self.driver).return_search_obj()
def setup_class(self): self.driver = init_driver() self.login_obj = Page(self.driver).get_login()
def setup_class(self): self.driver = init_driver() self.trans_obj = Page(self.driver).get_trans()
from selenium.webdriver.common.by import By from Page.page import Page from Base.get_driver import get_driver page_obj = Page( get_driver('com.yunmall.lc', 'com.yunmall.ymctoc.ui.activity.MainActivity')) # 点击我 page_obj.get_homepage().click_my_btn() # 选择已注册账号 page_obj.get_choice_page().click_login_exist() # 输入 page_obj.get_login_page().Login_in('18796773314', '1234567') # msg = (By.XPATH, '//*[contains(@text,"密码错误")]') # print(page_obj.get_login_page().get_element(msg, timeout=6, poll_frequency=0.5).text) print(page_obj.get_login_page().get_toast_msg('密码错误')) # # 个人页面 # page_obj.get_personal_page().get_per_text() # page_obj.get_personal_page().click_setting() # # 退出页面 # page_obj.get_setting().click_quit()
from Page.page import Page from Base.get_driver import get_driver page_obj = Page( get_driver("com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity")) page_obj.get_home_page_obj().click_my_btn() page_obj.get_sign_page_obj().click_exist_btn() page_obj.get_login_page_obj().login("111", "123") page_obj.get_login_page_obj().get_toast('此用户') page_obj.driver.quit()
def setup_class(self): # 获取驱动对象 self.driver = get_phone_driver( "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity") # 获取page 对象 self.page_obj = Page(self.driver)
def setup_class(self): self.a=Page(get_driver())
def setup_class(self): # 初始化driver self.driver = get_phone_driver( "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity") # 初始化统一入口类 self.page_obj = Page(self.driver)
def setup(self): self.action = Page().init_page_home
from selenium.webdriver.common.by import By from Base.get_driver import init_driver from Page.page import Page import time page_obj = Page(init_driver()) # 点击我 page_obj.get_home_page_obj().click_my_btn() # 点击已有账号 page_obj.get_sign_page_obj().click_exits_accout() # 登陆操作 page_obj.get_login_page_obj().login("1111", "1111") try: # 获取提示消息 to = page_obj.get_login_page_obj().search_element( (By.XPATH, "//*[contains(@text,'不存在')]"), timeout=5, poll=0.1) print(to.text) finally: time.sleep(5) page_obj.driver.quit()
def setup_class(self): self.driver = get_driver( "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity") self.page_obj = Page(self.driver)
def setup(self): self.action = Page().init_page_address
def setup(self): self.driver = init_driver() self.page = Page(self.driver) self.users = self.page.initloginpage.create_phone() self.user = str(self.users)