def test_temperature_status(browser): obj = MainPage(browser) text1 = obj._text(StatusLocator.TEMPERATURE) for i in range(3): time.sleep(3) text2 = obj._text(StatusLocator.TEMPERATURE) assert text1 != text2, f"Проверить обновление температуры процессора (1: {text1}, 2: {text2})"
def exec_script(driver,testpage,teststep,testdata): # 定义测试用例执行函数状态标志位 exec_script = True try: # 登录功能测试 if testpage == "登录": url = driver.current_url url = GetUrl(url)+'login' if driver.current_url != url: driver.get(url) login = LoginPage(driver,testdata) if teststep == '用户名': login.input_username(testdata) if teststep == '密码': login.input_password(testdata) if teststep == '登录': login.click_submit() time.sleep(5) if testpage == "主页": time.sleep(3) url = driver.current_url major = MainPage(driver,url) if teststep == '退出': userid = major.show_userid() major.exit_sys(driver) time.sleep(3) if testpage == "其他主页": pass except: exec_script =False url = GetUrl(driver.current_url) driver.get(url) return exec_script
def make_advertisement_for_existing_user(self, advertisement_info, user_info): self.page = MainPage(self.driver) self.page.make_advertisement() if "account" in self.driver.current_url: self.login(user_info) self.make_advertisement(advertisement_info)
def exec_script(driver, testpage, teststep, testdata): #定义测试用例执行函数状态标志位 exec_script = True try: #登录功能测试 if testpage == '登录': url = driver.current_url login = LoginPage(driver, url) if teststep == '用户名': login.input_user(testdata) # logger.info('输入用户名{}'.format(testdata)) if teststep == '密码': login.input_pwd(testdata) # logger.info('输入密码{}'.format(testdata)) if teststep == '登录': login.login() time.sleep(3) if testpage == '注册': pass if testpage == '主页': time.sleep(2) url = driver.current_url mainpage = MainPage(driver, url) if teststep == '退出': mainpage.exit_sys() time.sleep(2) if testpage == '其他主页': pass except: exec_script = False return exec_script
def exec_script(driver, testpage, teststep, testdata): #定义测试用例执行函数状态标志位 exec_script = True try: #登陆功能测试 if testpage == '登录': url = driver.current_url url = geturl(url) + 'user.php' if driver.current_url != url: driver.get(url) login = LoginPage(driver, testdata) if teststep == '用户名': login.input_username(testdata) if teststep == '密码': login.input_password(testdata) if teststep == '登录': login.click_submit() time.sleep(5) #注册功能测试 if testpage == '注册': url = driver.current_url url = geturl(url) + 'user.php?act=register' if driver.current_url != url: driver.get(url) userreg = RegistePage(driver, testdata) if teststep == '用户名': userreg.input_username(testdata) if teststep == 'email': userreg.input_email(testdata) if teststep == '密码': userreg.input_password(testdata) if teststep == '确认密码': userreg.input_comfirpwd(testdata) time.sleep(8) if teststep == '注册': userreg.click_submit() time.sleep(5) if testpage == '主页': time.sleep(3) url = driver.current_url mainpage = MainPage(driver, url) if teststep == '退出': mainpage.exit_sys() time.sleep(3) if testpage == '其他主页': pass except: exec_script = False url = geturl(driver.current_url) driver.get(url) return exec_script
class AutomatonWidgetCase(unittest.TestCase): def setUp(self): self.app = QtGui.QApplication(sys.argv) def testShowPage(self): self.window = MainPage() self.window.show() self.assertEqual(self.app.exec(), 0)
def test_cpu_status(browser): obj = MainPage(browser) text1 = obj._text(StatusLocator.POWER) for i in range(3): time.sleep(3) text2 = obj._text(StatusLocator.POWER) if text1 != text2: return True assert text1 != text2, f"Проверить обновление загрузки процессора (1: {text1}, 2: {text2})"
def make_advertisement_for_new_user(self, advertisement_info, user_info, mail): self.page = MainPage(self.driver) self.page.make_advertisement() if "account" in self.driver.current_url: self.registrate_new_user(user_info) # get link from email and activate account self.driver.get(mail.get_link_from_email_by_number(1)) self.page.make_advertisement() self.make_advertisement(advertisement_info)
def main_page(browser): logger = logging.getLogger('main_page fixture') logger.info("\nMain page loading ...") page = MainPage(browser) try: page.go_to() except TimeoutException: logger.exception("Main page not loaded") raise TimeoutException logger.info("\nMain page is opened") return page
def handleLogin(self): """Handle the login event.""" if self.parent.dbhelper.userExists(self.usernameEntry.get()): # login self.parent.CURRENT_USER = self.usernameEntry.get() winsound.PlaySound("SystemExclamation", winsound.SND_ASYNC) # I need to add the page here, otherwise it gets initialized at the # start, so the CURRENT_USER isn't set, thus is None. self.parent.pages[MainPage] = MainPage(self.parent) self.parent.change_page(MainPage) else: messagebox.showinfo("Oops", "No user was found with those details")
def test_call_protocol(browser, protocol): obj = MainPage(browser) obj.call(protocol, resolution=rand(0, 14), speed=rand(0, 19), fps=rand(0, 6)) obj.call_rezult(protocol) return
def test_call_number_h323(browser, number, protocol='H323'): obj = MainPage(browser) obj.call(protocol, number=number) obj.call_rezult(protocol, number=number) return
def test_call_speed_sip(browser, speed, protocol='SIP'): obj = MainPage(browser) obj.call(protocol, resolution=rand(0, 14), speed=speed, fps=rand(0, 6)) obj.call_rezult(protocol, speed=speed) return
def test_call_fps_sip(browser, fps, protocol='SIP'): obj = MainPage(browser) obj.call(protocol, resolution=rand(0, 14), speed=rand(0, 19), fps=fps) obj.call_rezult(protocol, fps=fps) return
def test_search_pope(br): MainPage(br).open_lang_list() MainPage(br).switch_to_language('Українська') MainPageLocalize(br).search("Пій 12\n") SearcResultPage(br).open_result('Пій XII') assert WikiPage(br).title == 'Пій XII — Вікіпедія'
def test_call_resolution_h323(browser, resolution, protocol='H323'): obj = MainPage(browser) obj.call(protocol, resolution=resolution, speed="1536", fps=rand(0, 6)) obj.call_rezult(protocol, resolution=resolution) return
def execStep(driver, testpage, teststep, testdata, testmsg, mylog): exec_step = True try: if testpage == 'login': # url = driver.current_url # url = getUrl(url) + '/require_login' # if driver.current_url != url: # driver.get(url) userlogin = LoginPage(driver) if teststep == 'username': userlogin.input_username(mylog, testdata) if teststep == 'password': userlogin.input_password(mylog, testdata) if teststep == 'login': userlogin.submit_click(mylog) time.sleep(3) if driver.current_url == testdata: assert (userlogin.show_errormessage(mylog) == testmsg) url = getUrl(driver.current_url) mylog.info("current url %s" % url) driver.get(url) # userlogin.go_to_indexpage(mylog) # time.sleep(3) # indexpage = IndexPage(driver) # indexpage.go_to_login(mylog) time.sleep(1) if testpage == 'login_success': mylog.info("now in login_success page") mainpage = MainPage(driver) if teststep == 'logout': assert (mainpage.show_usermessage(mylog)).startswith(testdata) mainpage.logout_from_login(mylog) assert driver.title == "login" mylog.info("current page has title %s" % driver.title) time.sleep(3) ###################################################################################################### if testpage == 'register': # url=driver.current_url # url=getUrl(url) + '/require_register' # if driver.current_url != url: # driver.get(url) userreg = RegisterPage(driver) if teststep == 'username': userreg.input_username(mylog, testdata) if teststep == 'email': userreg.input_email(mylog, testdata) if teststep == 'password': userreg.input_password(mylog, testdata) if teststep == 'confirmation': userreg.input_password2(mylog, testdata) if teststep == 'register': userreg.submit_click(mylog) time.sleep(3) if driver.current_url == testdata: assert (userreg.show_errormessage(mylog) == testmsg) url = getUrl(driver.current_url) mylog.info("current url %s" % url) driver.get(url) # userreg.go_to_indexpage(mylog) # time.sleep(3) # indexpage = IndexPage(driver) # indexpage.go_to_register(mylog) time.sleep(1) if testpage == 'register_success': mylog.info("now in register_success page") #url=driver.current_url mainpage = MainPage(driver) if teststep == 'home': assert (mainpage.show_usermessage(mylog)).startswith(testdata) mainpage.go_to_indexpage(mylog) assert driver.title == "myuser" mylog.info("in index page to click register button") indexpage = IndexPage(driver) indexpage.go_to_register(mylog) # mylog.info("go to index page to click register button") # indexpage=IndexPage(driver) # if teststep == 'register': # indexpage.go_to_register(mylog) # assert driver.title == "index" # mylog.info("current page has title %s" % driver.title) # time.sleep(3) mylog.info("current page has title %s" % driver.title) time.sleep(3) result = removeUser( testdata) # cleanup for signup related test cases mylog.info("remove ") # if testpage == 'index': # mylog.info("go to index page to click register button") # indexpage=IndexPage(driver) # if teststep == 'register': # indexpage.go_to_register(mylog) # assert driver.title == "index" # mylog.info("current page has title %s" % driver.title) # time.sleep(3) if testpage == 'other page': pass except: exec_step = False cappic(driver) url = getUrl(driver.current_url) mylog.info("current url %s" % url) driver.get(url) return exec_step
def setup_class(self): self.main = MainPage()
def test_call_number_sip_tls(browser, number, protocol='SIP_TLS'): obj = MainPage(browser) obj.call(protocol, number=number) obj.call_rezult('SIP', number=number) return
def registrate_new_user(self, user_info): self.page = AuthPage(self.driver) self.page.registrate_new_user(user_info)
def main(): app = QtGui.QApplication(sys.argv) mainWindow = MainPage() mainWindow.show() app.exec()
class TestLogic(BaseTest): def close_noisy_window(self): self.page.close_sms_verification() def registrate_new_user(self, user_info): self.page = AuthPage(self.driver) self.page.registrate_new_user(user_info) def login(self, user_info): self.page = AuthPage(self.driver) self.page.login(user_info) def make_advertisement(self, advertisement_info): self.close_noisy_window() self.page = AdvertPage(self.driver) self.page.place_advertisement(advertisement_info) self.assertTrue(self.page.is_message_show()) def make_advertisement_for_new_user(self, advertisement_info, user_info, mail): self.page = MainPage(self.driver) self.page.make_advertisement() if "account" in self.driver.current_url: self.registrate_new_user(user_info) # get link from email and activate account self.driver.get(mail.get_link_from_email_by_number(1)) self.page.make_advertisement() self.make_advertisement(advertisement_info) def make_advertisement_for_existing_user(self, advertisement_info, user_info): self.page = MainPage(self.driver) self.page.make_advertisement() if "account" in self.driver.current_url: self.login(user_info) self.make_advertisement(advertisement_info)
def test_check_title(self, driver): mainpage = MainPage(driver) with allure.step('Check title presence'): assert mainpage.is_block_title_present(), 'Title is not present on the mainpage.'
def login(self, user_info): self.page = AuthPage(self.driver) self.page.login(user_info)
def make_advertisement(self, advertisement_info): self.close_noisy_window() self.page = AdvertPage(self.driver) self.page.place_advertisement(advertisement_info) self.assertTrue(self.page.is_message_show())
def testShowPage(self): self.window = MainPage() self.window.show() self.assertEqual(self.app.exec(), 0)
def step_click_on_link(context): context.page = MainPage(context.browser) context.page.find_link().click()
def test_h323_status(browser): obj = MainPage(browser) assert obj.or_text(StatusLocator.H323_REGISTRATION_STATUS, "Not registered"), 'Проверить статус регистрации h323'
def test_first(get_driver): main1 = MainPage(get_driver) auth_page = main1.sign_in() my_account = auth_page.login("*****@*****.**", "12345678") main1 = my_account.home() searchres = main1.search("summer")
def test_dell_player(player): obj = MainPage(player) assert obj.dell_player_main( ) == True, "Не удалось удалить добавленный ролик"
def step_validate_location(context): context.browser.get( 'https://saucelabs-sample-test-frameworks.github.io/training-test-page' ) context.page = MainPage(context.browser)
def test_sip_status(browser): obj = MainPage(browser) assert obj.or_text(StatusLocator.SIP_REGISTRATION_STATUS, "Not registered"), "Проверить статус регистрации sip"
def test_call_player(player): obj = MainPage(player) obj.call_rolik() assert obj.call_off(), "Проблемы с вызовом ролика"