def attach_screenshot_on_failure(step): if step.state is not Step.State.FAILED: return stc_selenium = get_selenium_config(step.context) try: stc_selenium.attach_screenshot_to_tests_report(step) except: stc_selenium.log.exception('Getting screenshot error')
def user_submit_sign_in_form( self, step, ): """User submit Sign in form""" stc = get_selenium_config(step.context) sign_in_page = SignInPageObject(stc.driver) sign_in_page.submit()
def user_sumbit_the_new_article_form( self, step, ): """User sumbit the new article form""" stc = get_selenium_config(step.context) art = CreateArticlePageObject(stc.driver) art.submit()
def open_web_browser(scenario): stc_selenium = get_selenium_config(scenario.context) stc_selenium.log.info('Open web browser for scenario: {}'.format(scenario)) try: stc_selenium.open_browser() except Exception as e: stc_selenium.log.exception('Webdriver open problem: {}'.format(e)) stc_selenium.driver = None return stc_selenium.driver
def user_fill_sign_in_form_with_correct_data(self, step): """User fill Sign in form with correct data""" stc = get_selenium_config(step.context) stc_conduit = get_conduit_config(step.context) ConduitBaseSteps().user_navigate_to_sign_in_page(step) user_model = stc_conduit.test_data.data.get('user') sign_in_page = SignInPageObject(stc.driver) sign_in_page.user_fill_form(user_model.get('email'), user_model.get('password'))
def attach_console_log_on_failure(step): if step.state is not Step.State.FAILED: return stc_selenium = get_selenium_config(step.context) try: stc_selenium.attach_driver_console_log_to_test_report( step, stc_selenium.driver) except: stc_selenium.log.exception('Getting console log error')
def user_fills_the_sign_up_page(self, step): """User fills the Sign up page""" stc = get_selenium_config(step.context) stc_conduit = get_conduit_config(step.context) spo = SignupPageObject(stc.driver) faker_ = stc_conduit.faker username = faker_.user_name() userpass = faker_.password() useremail = faker_.email() spo.user_fill_form(username, useremail, userpass)
def close_web_browser(scenario): stc_selenium = get_selenium_config(scenario.context) stc_selenium.log.info( 'Close web browser for scenario: {}'.format(scenario)) if stc_selenium.driver: try: stc_selenium.driver.close() except: stc_selenium.log.exception('Driver close failure') stc_selenium.driver = None
def user_should_see_the_created_article(self, step): """User should see the created article""" stc = get_selenium_config(step.context) stc_conduit = get_conduit_config(step.context) art = ViewArticlePageObject(stc.driver) article = stc_conduit.test_data.data.get('last_article') current_title = art.read_title() current_article = art.read_article() assert_dict_contains_subset( { 'title': current_title, 'article': current_article }, article) stc.attach_screenshot_to_tests_report(step)
def user_fills_the_new_article_form( self, step, ): """User fills the new article form""" stc = get_selenium_config(step.context) stc_conduit = get_conduit_config(step.context) art = CreateArticlePageObject(stc.driver) f = stc_conduit.faker text = f.text() words = text.split() title = f.sentence(ext_word_list=words, nb_words=3) about = f.sentence(ext_word_list=words, nb_words=5) tag = f.word(ext_word_list=words) article = { 'article': text, 'title': title, 'tag': tag, 'about': about, } art.user_fill_form(article) article['article'] = article['article'].replace('\n', ' ') stc_conduit.test_data.data['last_article'] = article stc.attach_screenshot_to_tests_report(step)
def user_enter_email(self, step, email): """User enter email {email:QuotedString}""" stc = get_selenium_config(step.context) spo = SignupPageObject(stc.driver) spo.user_fill_form(email=email)
def user_should_be_logged_in(self, step): """User should be logged in""" stc = get_selenium_config(step.context) lp = NavigateConduitPageObject(stc.driver) assert_true(lp.user_is_logged_in(), "User should be logged in")
def user_navigate_to_new_post_page(self, step): """User navigate to create article page""" stc = get_selenium_config(step.context) NavigateConduitPageObject(stc.driver).user_navigate_to_new_post_page()
def user_navigate_to_sign_in_page(self, step): """User navigate to Sign in page""" stc = get_selenium_config(step.context) NavigateConduitPageObject(stc.driver).user_navigate_to_sign_in_page()
def user_opens_conduit_page(self, step): """User opens conduit page""" stc = get_selenium_config(step.context) open_web_browser(step) stc.driver.get(stc.cfg['conduit_frontend']['url'])
def user_submit_form(self, step): """User submit the Sign up page""" stc = get_selenium_config(step.context) rp = SignupPageObject(stc.driver) rp.submit() stc.attach_screenshot_to_tests_report(step)
def user_enter_username(self, step, username): """User enter username {username:QuotedString}""" stc = get_selenium_config(step.context) spo = SignupPageObject(stc.driver) spo.user_fill_form(username=username)
def _get_driver(self, context): stc_selenium = get_selenium_config(context) assert isinstance( stc_selenium.driver, WebDriver), f'{stc_selenium.driver} is not supported Driver' return stc_selenium.driver
def _attach_screenshot(self, step): stc_selenium = get_selenium_config(step.context) stc_selenium.attach_screenshot_to_tests_report(step)
def user_enter_password(self, step, password): """User enter password {password:QuotedString}""" stc = get_selenium_config(step.context) spo = SignupPageObject(stc.driver) spo.user_fill_form(password=password)
def page_title_should_contain(self, step, title): """page title should contain {title:QuotedString}""" stc_selenium = get_selenium_config(step.context) assert isinstance(stc_selenium.driver, WebDriver) assert_in(title, stc_selenium.driver.title) self._attach_screenshot(step)