def __init__(self): Page.__init__(self) self.url = '' self.pathes = { 'link': 'html body div#main div#tmp_campaign div#campain_border div.lsize ul li#col_left_part div.clear ul li#mid_part div#listing_page_narrow.mid_border form#fav div.listingVifUrl a.childVifUrl', } pass
def test_search(self, search_text, search_result): """内容输入 和 结果断言""" # 输入框 Page.get_page_sousuo().input_text(search_text) # 断言 -列表式断言 assert search_result in Page.get_page_sousuo().get_result()
def test_search_page(self, search_text, result_text): """ 搜索内容测试方法 :param search_text: 搜索内容 :param result_text: 搜索的结果 """ Page.search_page().send_search(search_text) assert result_text in Page.search_page().get_search_result()
def __init__(self): Page.__init__(self) self.base_url = '' self.pathes = { 'cells': '//table[contains(@id,"lessonList")]/tbody/tr/td[2]', 'href': './/a[1]/@href', 'title': './/a[1]/text()', } pass
class TestHslOpen: def setup_class(self): self.driver = get_phone_driver("com.hsl.stock", ".module.main.StartV2Activity") self.page = Page(self.driver) def teardown_class(self): self.driver.quit() @allure.severity(allure.severity_level.BLOCKER) @allure.step(title="打开app,进入我的页面,输入手机号密码,点击登陆") def test_01(self): self.page.open_hsl().open_rules_click_agrees() ass = self.page.open_hsl().get_result() allure.attach("13120683383", "手机号") allure.attach("aini1314", "密码") assert ass == "兔子人" # png_name = "./images" + os.sep + "{}.png".format(int(time.time())) png_time = "./images/%s.png" % int(time.time()) self.driver.get_screenshot_as_file(png_time) allure.attach.file(r"%s" % png_time, attachment_type=allure.attachment_type.PNG, name="Cileen") # ass = self.page.open_hsl().get_result() # assert ass == "涨停成功率" @allure.severity(allure.severity_level.CRITICAL) @allure.step(title="这是test02的测试步骤") def test_02(self): allure.attach.file(r"./adc.png", attachment_type=allure.attachment_type.PNG, name="Aileen") assert True @allure.severity(allure.severity_level.NORMAL) @allure.step(title="这是test03的测试步骤") def test_03(self): print("---->test02<----") assert False @allure.severity(allure.severity_level.MINOR) @allure.step(title="这是test04的测试步骤") def test_04(self): print("---->test03<----") assert True @allure.severity(allure.severity_level.TRIVIAL) @allure.step(title="这是test05的测试步骤") def test_05(self): print("---->test04<----") assert True
def __init__(self): Page.__init__(self) self.url = '' self.pathes = { 'description': '//span[contains(@class,"info")][1]/text()', 'rows': '//table[contains(@id,"wordTranslationList")]/tbody/tr', 'audio-href': './td[2]//a[1]/@href', 'text': './td[2]//span[1]/text()', 'translation': './td[3]//span[1]/text()', # 'tds': './td', 'audio-href-1': './td[1]//a[1]/@href', 'text-1': './td[1]//span[1]/text()', 'translation-1': './td[1]//span[1]/text()', } pass
def test_font_size(self): # # 选择小字体 # small_result = Page.view_page().get_choice_small_size_result() # # 断言小字体 # assert "小" in small_result # 选择普通字体 general_result = Page.view_page().get_choice_general_size_result() # 断言普通字体 assert "普通" in general_result # # 选择大字体 # big_result = Page.view_page().get_choice_big_size_result() # # 断言大字体 # assert "大" in big_result # 选择特大字体 sbig_result = Page.view_page().get_choice_super_big_size_result() # 断言特大字体 assert "超大" in sbig_result
class TestSet(object): def setup_class(self): self.driver = get_driver('com.android.settings', '.Settings') self.page = Page(self.driver) def teardown_class(self): self.driver.quit() @pytest.fixture(scope='class', autouse=True) @allure.step('点击搜索') def click_set_search_btn(self): self.page.set_page().click_search_btn() @pytest.mark.parametrize('test_num,text,exp', data_test()) @allure.step('测试设置搜索') @pytest.allure.severity(pytest.allure.severity_level.CRITICAL) def test_set_search(self, test_num, text, exp): allure.attach(test_num, '输入数据:%s,预期:%s' % (text, exp)) self.page.set_page().input_mes_search_bar(text) assert exp in self.page.set_page().get_search_ret_list()
class TestSet(object): def setup_class(self): self.driver = get_driver('com.android.settings', '.Settings') self.page = Page(self.driver) def teardown_class(self): self.driver.quit() def test_network(self): self.page.set_page().click_more_btn() self.page.more_page().click_mobile_btn() self.page.mobile_page().select_2G() assert '2G' in self.page.mobile_page().get_summary_ret_list()
def setup_class(self): self.driver = get_driver('com.android.settings', '.Settings') self.page = Page(self.driver)
def click_search(self): Page.setting_page().click_search_btn()
def click_view_btn(self): Page.setting_page().click_view_btn()
def setup_class(self): self.driver = get_phone_driver("com.hsl.stock", ".module.main.StartV2Activity") self.page = Page(self.driver)
class TestLoginTes: def setup_class(self): self.driver = get_phone_driver( "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity") self.page = Page(self.driver) def teardown_class(self): self.driver.quit() @pytest.fixture(autouse=True) def auto_in_login(self): self.page.get_main_page().mp_click_mine_btn() self.page.get_login_page().lp_click_go_login() @pytest.mark.parametrize("case_num, account, passwd, expect_data", get_login().get("suc")) def test_login_test_01(self, case_num, account, passwd, expect_data): self.page.get_login_page().lp_input_username(account) self.page.get_login_page().lp_input_password(passwd) self.page.get_login_page().lp_click_login_btn() try: shop_cart = self.page.get_mine_page().minep_get_result() try: assert expect_data in shop_cart except AssertionError: self.page.get_mine_page().screen_page() assert False finally: self.page.get_mine_page().minep_click_settings_btn() self.page.get_settings_page().sp_click_logout_btn() except TimeoutException: self.page.get_settings_page().screen_page() try: self.page.get_login_page().lp_if_login_btn() self.page.get_login_page().lp_click_close_login_page_btn() except TimeoutException: self.page.get_mine_page().minep_click_settings_btn() self.page.get_settings_page().sp_click_logout_btn() assert False @pytest.mark.parametrize("case_num, account, passwd, toast, expect_data", get_login().get("fail")) def test_login_fail(self, case_num, account, passwd, toast, expect_data): self.page.get_login_page().lp_input_username(account) self.page.get_login_page().lp_input_password(passwd) self.page.get_login_page().lp_click_login_btn() try: toast_data = self.page.get_settings_page().get_toast(toast) try: self.page.get_login_page().lp_if_login_btn() assert toast_data == expect_data self.page.get_login_page().lp_click_close_login_page_btn() except TimeoutException: self.page.get_settings_page().screen_page() self.page.get_mine_page().minep_click_settings_btn() self.page.get_settings_page().sp_click_logout_btn() assert False except AssertionError: self.page.get_settings_page().screen_page() self.page.get_login_page().lp_click_close_login_page_btn() assert False except TimeoutException: self.page.get_settings_page().screen_page() try: self.page.get_login_page().lp_if_login_btn() self.page.get_login_page().lp_click_close_login_page_btn() except TimeoutException: self.page.get_mine_page().minep_click_settings_btn() self.page.get_settings_page().sp_click_logout_btn() assert False
def test_slsq(self, dwmc, dz, ass, ywbm, gclx, czfs): logging.info("---------------->执行受理申请") Page.get_homePage().test_int_slsq() Page.get_slsqPage().test_slsq(dz) # 断言 assert is_exists_element(self.driver, ass)
def setup_class(self): self.driver = get_phone_driver( "com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity") self.page = Page(self.driver)
def test_login(self, username, password, ass): logging.info("---------------->执行登陆用例") # self.login_proxy.test_login(username, password) Page.get_loginPage().test_login(username, password) # 断言 assert is_exists_element(self.driver, ass)
class TestHslOpen: def setup_class(self): self.driver = get_phone_driver("com.hsl.stock", ".module.main.StartV2Activity") self.page = Page(self.driver) def teardown_class(self): self.driver.quit() # def teardown(self): # for i in range(4): # self.driver.back() # def test_01(self): # self.page.open_hsl().open_rules_click_agrees() # ass = self.page.open_hsl().get_result() # assert ass == "兔子人" @allure.step("打开app") @allure.step("然后不同意条约") @allure.step("再次打开app") @allure.story("首次打开app不同意用户协议") @allure.issue("https://www.bugclose.com/bug.html?id=51588&projectId=38335") @allure.testcase("https://www.bugclose.com/testCase.html?id=2065&projectId=38335") def test_open_hsl_refuse_rules(self): ''' 用例描述:首次打开app不同意用户协议和隐私政策会退出app,下次启动时仍然弹出条约弹窗 setup: 打开app step1: 不同意条约 step2: 确定以及肯定不同意 step3: 重新热启动打开app step4: 仍然首先弹出条约弹窗 assert:断言弹窗是否存在 ''' self.page.open_hsl().open_not_agree_rules() self.driver = get_phone_driver("com.hsl.stock", ".module.main.StartV2Activity") assert "具体要求点击上方红色" in self.page.open_hsl().get_hsl_rules_result() @allure.testcase("pass") def test_open_rules_right(self): allure.attach("这是一个文本信息", attachment_type=allure.attachment_type.TEXT) @allure.testcase("首次打开app同意用户协议") def test_open_hsl_agree_rules(self): self.page.open_hsl().open_agree_rules() # filename = "./images/tt.png" # self.driver.save_screenshot("./images/tt.png") # allure.attach.file(r"./images/tt.png", attachment_type=allure.attachment_type.PNG) @allure.testcase("登陆时不输入密码") def test_not_input_pwd_login(self): self.page.open_hsl().login_hsl_warning_password() @allure.testcase("滑动") def test_swipe(self): self.page.open_hsl().swipe_test() allure.attach(''' <div class="col-sm-12 bugTestTaskInfoDescription">前提条件:处于非活动期间<br>测试步骤:用户A打赏给操盘手B 91元,获得10天<br>预期结果:无法获得额外天数<br>实际结果:无法获得额外天数</div>''', attachment_type=allure.attachment_type.HTML) @allure.testcase("测试图片视频上传allure测试报告") def test_imp_MP4(self): allure.attach.file(r"C:\Users\86131\Desktop\图片\_{~~S[10I$(UQ8V9_]QG`)J.png", attachment_type=allure.attachment_type.JPG, name="Aileen") allure.attach.file(r"C:\Users\86131\Desktop\RPReplay_Final1599210159.MP4", attachment_type=allure.attachment_type.MP4, name="选股复现") def test_click_rules_screen_size(self): self.page.open_hsl().screen_press_in_rules()
""" 测试页面是否跑得通 """ from selenium.webdriver.common.by import By from base.page import Page # 首页关闭更新 Page.get_home().close_update() # 首页-我的 Page.get_home().click_my_btn() # 个人中心-登录注册 Page.get_person().click_login_sigin() # 登录操作 Page.get_login().login("15077632873", "xzynzyn") # 测试输入错误的密码 # 定位提升信息 # mess_xpath = (By.XPATH, "//*[contains(@text,'错误')]") # # 任意页面类都是集成了Base类,所以可以调用base类方法,search_ele为base类的方法 # message = Page.get_setting().search_ele(mess_xpath, timeout=3, poll_frequency=0.3).text # print("提示信息:", message) # # 点击返回按钮 # Page.get_login().login_return() # 因为该方法已经被封装。所以只需要调用即可get_login为任意去,为了调用base的方法 print("提示信息为:", Page.get_login().get_toast("错误")) # # 登录确认按钮 # Page.get_login().login_acc() # # 个人中心-打印用户名 # print("用户名:", Page.get_person().get_user_name())
def __init__(self): Page.__init__(self) self.url = '' self.pathes = { 'link': '//div[contains(@id,"navigation_bottom")]//div[contains(@class, "navigation_page")]/a[last()]/@href', }
def click_search_btn(self): """点击搜索按钮 1次 输入之前运行""" # 点击搜索 Page.get_page_shezhi().click_sousuobut()