def test_run(): mf = BasePage() # 登录 mf.test_login() # 找到我的任务 mf.test_loc_task() # 找到项目 mf.test_loc_project() # 找到用例 mf.test_loc_case()
def test_B1_7_3_01(self): u'''test_B1_7_3_01''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_teacher() self.browser.find_element_by_id('jsSearchBtn').click() self.assertIn('课程机构列表 - 慕学在线网', self.browser.title)
def test_B3_3_1_2(self): u'''test_B3_3_1_2''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_details() self.assertIn('讲师详情 - 慕学在线网', self.browser.title)
def main(): dev = devices.Device().get_devices() if not len(dev): print('there is no device connected this PC') return driver = webdriver.Remote('http://localhost:4723/wd/hub', dev[0]) base_page = BasePage.BasePage() base_page.set_driver(driver) testunit = unittest.TestSuite() testunit.addTests( map(testcase.freestore, ["test_login_logout", "test_mian"])) # testunit.addTest(testcase.freestore("test_mian")) # test_suit.addTests(map(Mydemo, ["Mytest1", "Mytest2", "Mytest3"])) now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) HtmlFile = "D:\\test\\" + now + "HTMLtemplate.html" fp = open(HtmlFile, "wb") runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title=u"测试报告", description=u"用例测试情况") runner.run(testunit) fp.close()
def test_B1_7_3_05(self): u'''test_B1_7_3_05''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_teacher() self.browser.find_element_by_id('search_keywords').send_keys('华中科技大学') self.browser.find_element_by_id('jsSearchBtn').click() self.assertIn('课程讲师 - 慕学在线网', self.browser.title)
def test_B1_7_1_04(self): u'''test_B1_7_1_04''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_course() self.browser.find_element_by_id('search_keywords').send_keys('武剑洁') self.browser.find_element_by_id('jsSearchBtn').click() self.assertIn('公开课列表 - 慕学在线网', self.browser.title)
def test_B3_3_1_4(self): u'''test_B3_3_1_4''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_details() teacher_page.click_detail_course() self.assertIn('课程详情页 - 慕学在线网', self.browser.title)
def test_B1_7_3_06(self): u'''test_B1_7_3_06''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_teacher() self.browser.find_element_by_id('search_keywords').send_keys( '~!@#$%^&*()_+|{}:"<>?.,;\'[]\=-') self.browser.find_element_by_id('jsSearchBtn').click() self.assertIn('课程讲师 - 慕学在线网', self.browser.title)
def test_B1_7_3_07(self): u'''test_B1_7_3_07''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_teacher() self.browser.find_element_by_id('search_keywords').send_keys( '<input type="text" id="txt" value="测试"/>') self.browser.find_element_by_id('jsSearchBtn').click() self.assertIn('课程讲师 - 慕学在线网', self.browser.title)
def test_B2_4_2(self): u'''test_B2_4_2''' course_page = BasePage.CoursePage(self.browser) course_page.click_course() course_page.click_sort_num() course_page.click_course_se() self.assertTrue( course_page.is_element_exist( '/html/body/section[2]/div/div/ul/li[3]'), 'ERROR')
def setUp(self): print('开始') self.browser = webdriver.Firefox() self.browser.get('http://111.230.45.33:3000/') login_page = BasePage.LoginPage(self.browser) login_page.click_loginButton() login_page.set_username("yankai") login_page.set_password("abc123456") login_page.click_login()
def test_B4_2_1_3(self): u'''test_B4_2_1_3''' insti_page = BasePage.InstiPage(self.browser) insti_page.click_insti() insti_page.click_class_all() insti_page.click_province_all() insti_page.click_list_course() insti_page.click_contact() self.assertIn('机构首页', self.browser.title)
def setUpClass(cls): print("开始测试") cls.browser = webdriver.Firefox() cls.browser.get('http://111.230.45.33:3000/') login_page = BasePage.LoginPage(cls.browser) login_page.click_loginButton() login_page.set_username("yankai") login_page.set_password("abc123456") login_page.click_login()
def test_B2_4_1_2_3(self): u'''test_B2_4_1_2_3''' course_page = BasePage.CoursePage(self.browser) course_page.click_course() course_page.click_sort_num() course_page.click_course_ds() course_page.click_collection() self.assertTrue( self.browser.find_element_by_id('jsLeftBtn').text == '收藏', 'ERROR')
def test_B2_4_1_3_1(self): u'''test_B2_4_1_3_1''' course_page = BasePage.CoursePage(self.browser) course_page.log_out() course_page.click_course() course_page.click_sort_num() course_page.click_course_ds() course_page.click_insti_collection() self.assertIn('慕学在线网登录', self.browser.title) course_page.log_in()
def test_B1_7_2_04(self): u'''test_B1_7_2_04''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_insti() self.browser.find_element_by_id('search_keywords').send_keys('武剑洁') self.browser.find_element_by_id('jsSearchBtn').click() self.assertTrue( home_page.is_element_exist('/html/body/section[3]/div/div[2]/div'), 'ERROR') # 我要学习
def test_B2_3_1_1_1(self): u'''test_B2_3_1_1_1''' course_page = BasePage.CoursePage(self.browser) course_page.log_out() course_page.click_course() course_page.click_sort_hot() course_page.click_course_ds() course_page.click_start_learn() self.assertIn('慕学在线网登录', self.browser.title) course_page.log_in()
def test_B4_3_1_15(self): u'''test_B4_3_1_15''' insti_page = BasePage.InstiPage(self.browser) insti_page.click_insti() insti_page.click_want_name('闫') insti_page.click_want_phone('13904367258') insti_page.click_want_course('复变函数') insti_page.click_want_contact() s = insti_page.click_alert() self.assertTrue(s == 1, 'ERROR')
def test_B4_3_1_16(self): u'''test_B4_3_1_16''' insti_page = BasePage.InstiPage(self.browser) insti_page.click_insti() insti_page.click_want_name('闫') insti_page.click_want_phone('13904367258') insti_page.click_want_course('~!@#$%^&*()_+|{}:"<>?.,;\'[]\=-') insti_page.click_want_contact() s = insti_page.click_alert() self.assertTrue(s == 1, 'ERROR')
def test_B3_3_2(self): u'''test_B3_3_2''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_ranklist_teacher() self.assertTrue( self.browser.find_element_by_xpath( "/html/body/section[3]/div/div[1]/div[1]/div/dl/dd/a/h1").text == '刘小峰金牌讲师', 'ERROR')
def test_B3_3_1_1_3(self): u'''test_B3_3_1_1_3''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_details() if not teacher_page.judge_detail_collection(): teacher_page.click_detail_collection() self.assertTrue( self.browser.find_element_by_id('jsLeftBtn').text == '收藏', 'ERROR')
def test_B3_3_1_3_1(self): u'''test_B3_3_1_3_1''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.log_out() teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_details() teacher_page.click_detail_insti_collection() self.assertIn('慕学在线网登录', self.browser.title) teacher_page.log_in()
def test_B2_3_1_3_2(self): u'''test_B2_3_1_3_2''' course_page = BasePage.CoursePage(self.browser) course_page.click_course() course_page.click_sort_hot() course_page.click_course_ds() course_page.click_insti_collection() self.assertTrue( self.browser.find_element_by_id('jsRightBtn').text == '已收藏', 'ERROR')
def test_B3_3_1_1(self): u'''test_B3_3_1_1''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.log_out() teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_details() self.assertIn('讲师详情 - 慕学在线网', self.browser.title) self.browser.find_element_by_link_text("登录").click() teacher_page.log_in()
def test_B1_7_1_03(self): u'''test_B1_7_1_03''' home_page = BasePage.HomePage(self.browser) home_page.return_homePage() home_page.click_search_course() self.browser.find_element_by_id('search_keywords').send_keys('数据结构') self.browser.find_element_by_id('jsSearchBtn').click() self.assertTrue( home_page.is_element_exist( '/html/body/section[3]/div/div/div[1]/div[2]/div/div[1]/div/div[1]/a/h2' ), 'ERROR') # 数据结构
def setUp(self): # desired_caps = {} # desired_caps['platformName'] = 'Android' # 设备系统 # desired_caps['platformVersion'] = '4.4.2' # 设备系统版本 # desired_caps['deviceName'] = '127.0.0.1:62001' # 设备名称 # desired_caps['appPackage'] = 'com.first.saccelerator' # 测试app包名 # desired_caps['appActivity'] = 'com.first.saccelerator.ui.activity.CheckPermissionsActivity' # 测试appActivity # desired_caps['noReset'] = True # self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) # 启动app # self.driver.implicitly_wait(10) self.driver = BasePage.Base().get_driver()
def test_B3_3_1_2_1(self): u'''test_B3_3_1_2_1''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.click_teacher() teacher_page.click_polpularity() teacher_page.click_details() teacher_page.click_detail_share() self.assertTrue( self.browser.find_element_by_xpath( "/html/body/section[3]/div/div[1]/div[1]/div/dl/dt/div[2]/span[2]/a" ).text == '已分享', 'ERROR')
def test_B3_2_1_3_2(self): u'''test_B3_2_1_3_2''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.click_teacher() teacher_page.click_all() teacher_page.click_details() if teacher_page.judge_detail_insti_collection(): teacher_page.click_detail_insti_collection() self.assertTrue( self.browser.find_element_by_id('jsRightBtn').text == '已收藏', 'ERROR')
def _run_cases(run): driver = webdriver.Remote( str('http://localhost:%s/wd/hub') % run.get_port()[0], run.get_device()) base_page = BasePage.BasePage() base_page.set_driver(driver) # run.run(cases) driver.find_element_by_id( 'com.snailgame.cjg:id/tab_free_store').click() driver.quit()
def test_B3_2_1_1_1(self): u'''test_B3_2_1_1_1''' teacher_page = BasePage.TeacherPage(self.browser) teacher_page.log_out() teacher_page.click_teacher() teacher_page.click_all() teacher_page.click_details() teacher_page.click_detail_collection() self.assertIn('慕学在线网登录', self.browser.title) if self.browser.title != '慕学在线网登录': self.browser.find_element_by_link_text("登录").click() teacher_page.log_in()