def login_if_necessary_for_component(TargetPage, responsive_target): print("*** login_if_necessary_for_component setup ***") print("target page: {0} and target ssize: {1} and".format(TargetPage.name, responsive_target['size_type'])) if TargetPage.name in cfg.member_only_pages: print("*** login required at {}".format(TargetPage.name)) login_page = LoginPage(responsive_target['driver']) login_page.type_text_in_input(locator='email_input', text=cfg.test_user_email_for_profile) login_page.type_text_in_input(locator='password_input', text=cfg.test_user_password_for_profile) login_page.type_text_in_input(locator='confirm_input', text=cfg.test_user_password_for_profile) login_page.click_element('submit_btn') home_page = HomePage(responsive_target['driver'], independent=False) home_page.wait_for_element('slogan') yield None if TargetPage.name in cfg.member_only_pages: print("*** logout required at {}".format(TargetPage.name)) home_page = HomePage(responsive_target['driver'], independent=False) # home_page.wait_for_element('slogan') if responsive_target['size_type'] != 'desktop': print("*** desktop size requires open nav menu***") home_page.click_element_in_header('menu_toggle_icon', waiting_element_locator=None, animation_duration_sc=cfg.animation_duration_sc) home_page.click_element_in_header('logout_menu_link')
def test_should_route_signup_page_when_join_btn_is_clicked_in_home( responsive_target): home_page = HomePage(responsive_target['driver']) # click join btn home_page.click_element('join_btn') # get signup page object with current url signup_page = SignupPage(responsive_target['driver']) # assert signup page is correctly loaded assert signup_page.does_have_text_in_page('Signup')
def test_singup_page_should_route_home_page_when_successfully_signup(responsive_target): signup_page = SignupPage(responsive_target['driver']) signup_page.type_text_in_input(locator='name_input', text='dummy user') # use fake email address to avoid duplication of existing email signup_page.type_text_in_input(locator='email_input', text=fake.email()) signup_page.type_text_in_input(locator='password_input', text='dummy') signup_page.type_text_in_input(locator='confirm_input', text='dummy') signup_page.click_element('submit_btn') home_page = HomePage(responsive_target['driver'], independent=False) # if fetch and move pages, you need to wait for fetch done and next page is loaded like below otherwise, selenium can assert before target element is loaded home_page.wait_for_element('slogan') assert home_page.does_have_text_in_page('Share Your Knowledge and Expand What You Can Do')
def test_singup_page_should_route_home_page_when_successfully_login( responsive_target): login_page = LoginPage(responsive_target['driver']) login_page.type_text_in_input(locator='email_input', text=cfg.test_user_email) login_page.type_text_in_input(locator='password_input', text=cfg.test_user_password) login_page.type_text_in_input(locator='confirm_input', text=cfg.test_user_password) login_page.click_element('submit_btn') home_page = HomePage(responsive_target['driver'], independent=False) # if fetch and move pages, you need to wait for fetch done and next page is loaded like below otherwise, selenium can assert before target element is loaded home_page.wait_for_element('slogan') assert home_page.does_have_text_in_page( 'Share Your Knowledge and Expand What You Can Do')
def login(target_driver): print("*** login module scope setup ***") # set target driver ssize to desktop # this is because each driver has its differnt default ssize so make it consistent # don't need to worry about modify ssize here, this fixture is called before 'responsive_target' # fixture so it is overrided to collect ssize at the fixture. target_driver.set_window_size(cfg.ssize_width_tablet, cfg.ssize_height) login_page = LoginPage(target_driver) login_page.type_text_in_input(locator='email_input', text=cfg.test_user_email_for_profile) login_page.type_text_in_input(locator='password_input', text=cfg.test_user_password_for_profile) login_page.type_text_in_input(locator='confirm_input', text=cfg.test_user_password_for_profile) login_page.click_element('submit_btn') home_page = HomePage(target_driver, independent=False) home_page.wait_for_element('slogan') return home_page
def test_should_fetch_popular_blog_when_click_popular_btn(responsive_target): home_page = HomePage(responsive_target['driver']) # get one of blog title before click 'popular' btn blog_title_before_click = home_page.get_one_of_blog_title() # click 'popular' btn home_page.click_element('popular_btn', 'blog_item_title') # don't need to wait the blog item appears since 'click_popular_btn' does that for you # get one of blog title after click 'popluar' btn blog_title_after_click = home_page.get_one_of_blog_title() # #TODO: fix implementation so that 'popular' click run different query # after fix this, this should pass assert blog_title_before_click != blog_title_after_click
def test_should_route_search_result_page_when_search_in_home( responsive_target): home_page = HomePage(responsive_target['driver']) # open search input home_page.click_element('search_btn') # enter text in the input and press 'enter' home_page.enter_text_in_search_input('test') # page moves to Blog List page blog_list_page = BlogListPage(responsive_target['driver']) # assert signup page is correctly loaded assert blog_list_page.does_have_text_in_page('Blog List')
def test_blog_page_should_display_blog_at_blog_page(responsive_target): home_page = HomePage(responsive_target['driver']) home_page.wait_for_element('blog_item') target_blog_item = home_page.get_one_of_blog_items(0) target_blog_title = target_blog_item.text # home_page.wait_for_element_to_be_visible(element=target_blog_item) target_blog_item.click() # home_page.click_element('blog_item') home_page.wait_for_animation_finish() blog_page = BlogPage(responsive_target['driver'], independent=False) blog_page.wait_for_element('blog_page_title') target_blog_page_title = blog_page.get_text_of_element('blog_page_title') assert target_blog_page_title in target_blog_title
def test_should_display_5_blog_item_at_initial_load(responsive_target): home_page = HomePage(responsive_target['driver']) assert 5 == home_page.get_number_of_blog_item_displayed()