class TestCCHQ(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(inputs.base_url) login_page = Login(self.driver) login_page.accept_cookies() login_page.enter_username(inputs.login_username) login_page.enter_password(inputs.login_password) login_page.click_submit() def test_exports(self): driver = self.driver export = Exports(driver) try: export.form_exports() time.sleep(2) export.validate_downloaded_form_exports() time.sleep(2) export.case_exports() time.sleep(2) #export.validate_downloaded_case_exports() #except Exception as e: # print(e) finally: print("We are in!") time.sleep(2)
class TCHowShiftWorks(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.how_shift_works_url) def test_how_shift_works_components(self): how_shift_works = HowShiftWorks(self.driver) # Upper Menu how_shift_works.validate_shift_icon_present() how_shift_works.validate_location_menu_present() how_shift_works.validate_heart_icon_id_present() how_shift_works.validate_browse_cars_present() how_shift_works.validate_sell_your_car_present() how_shift_works.validate_financing_present() how_shift_works.validate_how_shift_works_link_present() how_shift_works.validate_more_present() how_shift_works.validate_sign_in_present() # Buttons ans links how_shift_works.validate_browse_the_best_link() how_shift_works.validate_test_drives_link() how_shift_works.validate_no_hassle_buying() how_shift_works.validate_see_for_yourself() how_shift_works.validate_inspection() how_shift_works.validate_read_reviews_on_yelp() how_shift_works.validate_meet_our_concierges() how_shift_works.validate_browse_cars_btn() def tearDown(self): self.driver.instance.quit()
class TestPeek(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) #Validates first use case. Verify that search filters correctly applies and category applies based on value from strings.py def test_validate_pages_data(self): home_screen = HomeScreen(self.driver) home_screen.setLocationValue() home_screen.click_search_button() search_page = SearchPage(self.driver) initial_search_location = search_page.search_result_location() assert search_value == initial_search_location #Validates second use case. Verify that personality quiz works correctly and search, based on quiz results, return correct categories. def test_validate_quiz(self): home_screen = HomeScreen(self.driver) self.driver.instance.implicitly_wait(30) for image in range(0, 9): home_screen.personality_quiz_image() results = home_screen.get_personality_results() home_screen.search_with_quiz_results() search_page = SearchPage(self.driver) personality_quiz_search = search_page.input_values_in_seach_box( results) assert results in personality_quiz_search #Validates third use case. Verify calendar and booking works correctly. def test_validate_book_an_activity(self): home_screen = HomeScreen(self.driver) home_screen.check_activity_calendar() activity_page = ActivityPage(self.driver) activity_page.validate_available_day_for_booking() activity_page.validate_book_now_button() #Validates third use case. When user icrease the number of selected tickets beyond the availability, widget doesn't allow you to book an activity for that day. def test_validate_counting_tickets(self): home_screen = HomeScreen(self.driver) home_screen.validate_attractions() activity_page = ActivityPage(self.driver) activity_page.validate_book_now_button() activity_page.validate_tickets() def tearDown(self): self.driver.instance.quit()
class verifyMessageTest(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_displayedMessage(self): home_screen = HomeScreen(self.driver) home_screen.validate_message_displayed() def tearDown(self): self.driver.instance.quit()
class PythonCy(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(mnemonics.home) def test_search_product_check_out(self): search = Homepage(self.driver) search.search_item() def tearDown(self): self.driver.instance.quit()
class TestWatch(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_home_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.validate_card_title_is_present() home_screen.validate_login_button_is_present() home_screen.validate_credential_fields_are_present() home_screen.validate_register_link_is_present() def tearDown(self): self.driver.instance.quit()
class TestQABoy(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_home_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.validate_title_is_present() home_screen.validate_icon_is_present() home_screen.validate_menu_options_are_present() home_screen.validate_posts_are_visible() home_screen.validate_social_media_links() def tearDown(self): self.driver.instance.quit()
class TestDynPage(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_page_texts(self): page = FirstPage(self.driver) page.validate_long_word_exist() page.print_longest_word() def test_page_images(self): page = FirstPage(self.driver) page.print_images_names() page.validate_punisher_image() def tearDown(self): self.driver.instance.quit()
class TestInstagram(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_verify_username_character_limit(self): sign_up_page = SignUpPage(self.driver) sign_up_page.write_username(strings.long_username) sign_up_page.verify_character_count(30) def test_verify_required_fields(self): sign_up_page = SignUpPage(self.driver) sign_up_page.write_email_or_phone(strings.invalid_email) sign_up_page.click_next_button() sign_up_page.verify_form_errors(3) def test_login_button_is_not_present(self): sign_up_page = SignUpPage(self.driver) sign_up_page.verify_login_button_is_not_present()
class TestQABoy(unittest.TestCase): # Method will run before each of our test cases def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) # The method name will begin with 'test_' # because pytest needs this naming convention to identify al the test cases in our class. def test_home_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.validate_title_is_present() home_screen.validate_icon_is_present() home_screen.validate_menu_options_are_present() home_screen.validate_posts_are_visible() home_screen.validate_social_media_links() # Method will run after each of our test cases def tearDown(self): self.driver.instance.quit()
class LoginVerification(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.instance.maximize_window() self.driver.navigate(strings.base_url) def test_user_login_with_invalid_credentials(self): page = UserLogin(self.driver) page.login_to_user_portal("*****@*****.**", "password")\ .verify_warning_message(expected_message="The user or password is incorrect.") def test_reseller_login_with_invalid_credentials(self): page = NavigationScenarios(self.driver) page.navigate_to_reseller_portal_page()\ .login_to_reseller_portal("*****@*****.**", "password")\ .verify_error_message(expected_message="401 Client Error:") def tearDown(self): self.driver.instance.quit()
class TCHomeScreen(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_home_screen(self): home_screen = HomeScreen(self.driver) # Upper MENU home_screen.validate_shift_icon_present() home_screen.validate_location_menu_present() home_screen.validate_heart_icon_id_present() home_screen.validate_browse_cars_present() home_screen.validate_sell_your_car_present() home_screen.validate_financing_present() home_screen.validate_how_shift_works_link_present() home_screen.validate_more_present() home_screen.validate_sign_in_present() # Others # home_screen.validate_cars_list_is_visible() def tearDown(self): self.driver.instance.quit()
class TestTechBuddyLogin(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_logo_and_title_are_displayed(self): page = ServicesPage(self.driver) page.page_title_equals_to(strings.services_page_title) page.logo_is_displayed() def test_choose_a_service_correct_mobile_and_sms_code(self): page = ServicesPage(self.driver) page.choose_service_type() page.choose_category() page.choose_service() page.input_mobile_num(strings.correct_mobile_number) page.input_sms_code(strings.correct_sms_code) page.validate_correct_name_is_displayed() def test_choose_a_service_incorrect_mobile(self): page = ServicesPage(self.driver) page.choose_service_type() page.choose_category() page.choose_service() page.input_mobile_num(strings.incorrect_mobile_number_digits) page.validate_error_message_is_displayed() def test_choose_a_service_correct_mobile_incorrect_sms_code(self): page = ServicesPage(self.driver) page.choose_service_type() page.choose_category() page.choose_service() page.input_mobile_num(strings.correct_mobile_number) page.input_sms_code(strings.incorrect_sms_code) page.validate_error_message_is_displayed() def tearDown(self): self.driver.instance.quit()
class TestQABoy(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url) def test_home_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.validate_title_is_present() home_screen.validate_icon_is_present() home_screen.validate_menu_options_are_present() home_screen.validate_posts_are_visible() home_screen.validate_social_media_links() def test_about_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.click_about_me_link() about_screen = AboutScreen(self.driver) about_screen.validate_title_is_present() about_screen.validate_icon_is_present() about_screen.validate_menu_options_are_present() about_screen.validate_social_media_links() about_screen.validate_about_me_header() about_screen.validate_about_me_post() def test_post_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.click_first_post() post_screen = PostScreen(self.driver) post_screen.validate_title_is_present() post_screen.validate_icon_is_present() post_screen.validate_menu_options_are_present() post_screen.validate_social_media_links() post_screen.validate_featured_image() post_screen.validate_published_date() post_screen.validate_share_buttons() post_screen.validate_categories_and_tags() post_screen.validate_comment_section() def test_search_for_article(self): sidebar = SideBar(self.driver) sidebar.search_for_article(strings.article_title) search_screen = SearchScreen(self.driver) search_screen.click_article(strings.article_title) post_screen = PostScreen(self.driver) post_screen.validate_article_title(strings.article_title) def test_check_user_comment(self): sidebar = SideBar(self.driver) sidebar.click_user_comment() post_screen = PostScreen(self.driver) post_screen.validate_comment_section() def test_archived_articles(self): sidebar = SideBar(self.driver) sidebar.click_archive() def test_article_categories(self): sidebar = SideBar(self.driver) sidebar.click_category() def tearDown(self): self.driver.instance.quit()
class TestQABoy(unittest.TestCase): def setUp(self): '''setUp method will run before - each of our test cases (set up driver, launch site and other)''' self.driver = Driver() self.driver.navigate(strings.base_url) def test_home_page_components(self): home_page = HomePage(self.driver) home_page.validate_title_is_present() home_page.validate_icon_is_present() home_page.validate_menu_options_are_present() home_page.validate_posts_are_visible() home_page.validate_social_media_links() def test_about_page_components(self): home_page = HomePage(self.driver) home_page.click_about_me_link() about_page = AboutPage(self.driver) about_page.validate_title_is_present() about_page.validate_icon_is_present() about_page.validate_menu_options_are_present() about_page.validate_social_media_links() about_page.validate_about_me_header() about_page.validate_about_me_post() def test_post_page_components(self): home_page = HomePage(self.driver) home_page.click_first_post() post_page = PostPage(self.driver) post_page.validate_title_is_present() post_page.validate_icon_is_present() post_page.validate_menu_options_are_present() post_page.validate_social_media_links() post_page.validate_post_image() post_page.validate_published_date() post_page.validate_share_buttons() post_page.validate_comment_section() def test_search_for_article(self): sidebar = SideBar(self.driver) sidebar.search_for_article(strings.article_title) search_page = SearchPage(self.driver) search_page.click_article(strings.article_title) post_page = PostPage(self.driver) post_page.validate_article_title(strings.article_title) def test_check_user_comment(self): sidebar = SideBar(self.driver) sidebar.click_user_comment() post_screen = PostPage(self.driver) post_screen.validate_comment_section() def test_article_categories(self): sidebar = SideBar(self.driver) sidebar.click_category() def tearDown(self): '''tearDown method will run after - each of our test cases (clean up anything we did with our test case and quit the web driver)''' # Remember to always use “quit” instead of “close”. # If we used close, that would close the site but the instance of the web driver would remain alive. self.driver.instance.quit()
class TestAllApps(unittest.TestCase): def setUp(self): self.driver = Driver() # self.driver.navigate(strings.base_url) def tflx_login(self): self.driver.navigate(strings.tflx_p_url) self.user_name_field = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//input[@id='username']"))) self.password_field = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//input[@id='password']"))) self.log_in_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//button[@id='loginButton']"))) self.user_name_field.send_keys(strings.shared_un) self.password_field.send_keys(strings.shared_pw) self.log_in_btn.click() def tflx_rand_cat_selector(self): self.rand_cat_list = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_all_elements_located((By.ID, "moreButton"))) print('list has', len(self.rand_cat_list), 'cats') self.rand_cat = random.choice(self.rand_cat_list) self.cat_name_attrib = self.rand_cat.get_attribute("data-useraction-linkname") # print(self.cat_name_attrib) self.cat_name_txt = self.cat_name_attrib[self.cat_name_attrib.find(':') + 1: ] # print(self.cat_name_txt) self.cat_name_txt_normalized = ' '.join(self.cat_name_txt.split('_')).lower() print(self.cat_name_txt_normalized) self.rand_cat.click() return self.cat_name_txt_normalized def tflx_rand_unit_selector(self): self.rand_unit_list = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_all_elements_located((By.XPATH, ".//div[@class='browsebookcover']/a[contains(@href, '/p/node-')]"))) print('list has', len(self.rand_unit_list), 'units') self.rand_unit = random.choice(self.rand_unit_list) self.unit_name_attrib = self.rand_unit.get_attribute("data-useraction-linkname") self.unit_name_txt = self.unit_name_attrib[self.unit_name_attrib.find(':') + 1:] self.unit_name_txt_normalized = ' '.join(self.unit_name_txt.split('_')).lower() print(self.unit_name_txt_normalized) self.rand_unit.click() return self.unit_name_txt_normalized def tflx_login_rand_cat_rand_unit(self): self.tflx_login() self.cat = self.tflx_rand_cat_selector() self.unit = self.tflx_rand_unit_selector() return(self.cat, self.unit) def tflx_watch_video(self): self.watch_video_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//li[@class='watch_video_pair_button']/a[contains(@href, '/video/node-')]"))) self.watch_video_btn.click() self.play_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.CLASS_NAME, "vjs-limelight-big-play"))) self.play_btn.click() def tflx_open_ebook(self): self.ebook_launcher = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//img[@usemap='#openbook'][@id='readit_image']"))) self.ebook_launcher.click() def tflx_click_ex_more(self): self.ex_more_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.CLASS_NAME, "explore_more_pair_button"))) self.ex_more_btn.click() def tflx_click_rand_ex_more_art(self): self.ex_more_art_list = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_all_elements_located((By.XPATH, ".//a[contains(@href, '/exploremore/')]"))) print('found', len(self.ex_more_art_list), 'articles') self.rand_ex_more_art = random.choice(self.ex_more_art_list) self.rand_art_name_attrib = self.rand_ex_more_art.get_attribute("data-useraction-linkname") self.rand_art_name_txt = self.rand_art_name_attrib[self.rand_art_name_attrib.find(':') + 1:] self.rand_art_name_txt_normalized =' '.join(self.rand_art_name_txt.split('_')).lower() self.rand_ex_more_art.click() return self.rand_art_name_txt_normalized def tflx_click_proj_idea(self): self.proj_idea_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.CLASS_NAME, "projectidea_pair_button"))) self.proj_idea_btn.click() def tflx_click_show_know(self): self.show_know_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//a[@data-useraction-linkname='show_what_you_know']"))) self.show_know_btn.click() @allure.step('tflx log in with proper creds') def test_tflx_login(self): # screen = pageobjects.tflx.loginscreen.TflxLogInScrn(self.driver) # screen.test_tflx_login() self.tflx_login() tflx_header = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//div[@id='mainheadercontainer']"))) assert tflx_header.is_displayed() @allure.step('tflx randomly select a category') def test_tflx_select_cat(self): self.tflx_login() self.expected_cat = self.tflx_rand_cat_selector() self.cat_heading = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.ID, "browseHeading"))) self.cat_heading_txt = self.cat_heading.text self.cat_heading_txt_normalized = self.cat_heading_txt.lower() print(self.cat_heading_txt) self.assertEqual(self.expected_cat, self.cat_heading_txt_normalized) # @allure.step('tflx randomly select a unit') # def test_select_unit(self): # self.cat, self.unit = self.tflx_login_rand_cat_rand_unit() # # self.expected_unit = self.unit # print(self.expected_unit) # self.unit_name = WebDriverWait(self.driver.instance, 10).until( # EC.visibility_of_element_located((By.XPATH, ".//script[@type='text/javascript']"))) # unable to get to element @allure.step('tflx open and play a video') def test_video_playing(self): self.cat, self.unit = self.tflx_login_rand_cat_rand_unit() self.tflx_watch_video() self.pause_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//button[@class='vjs-play-control vjs-control vjs-button vjs-playing'][@title='Pause']"))) assert self.pause_btn.is_displayed() @allure.step('tflx open an ebook') def test_open_ebook(self): self.cat, self.unit = self.tflx_login_rand_cat_rand_unit() self.tflx_open_ebook() self.ereader_iframe = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//iframe[@id='ifrm']"))) self.driver.instance.switch_to.frame(self.ereader_iframe) self.ereader_toc_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//button[@title='Open Content Drawer']"))) assert self.ereader_toc_btn.is_displayed() self.driver.instance.switch_to.default_content() self.ereader_close_btn = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.ID, "btn_close"))) assert self.ereader_close_btn.is_displayed() @allure.step('tflx open random explore more article') def test_open_explore_more_art(self): self.cat, self.unit = self.tflx_login_rand_cat_rand_unit() self.tflx_click_ex_more() self.expected_name = self.tflx_click_rand_ex_more_art() self.tflx_ex_more_heading = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//h1"))).text self.tflx_ex_more_heading_normalized = self.tflx_ex_more_heading.lower() print('art name is', self.expected_name, 'and heading name is', self.tflx_ex_more_heading_normalized) self.assertEqual(self.expected_name, self.tflx_ex_more_heading_normalized) @allure.step('tflx open project idea') def test_open_project_idea(self): self.cat, self.unit = self.tflx_login_rand_cat_rand_unit() self.expected_name = self.unit self.tflx_click_proj_idea() self.proj_idea_heading = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//h1"))).text self.proj_idea_proj_title = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//div[@class='headingitem']/h2[contains(text(),'TrueFlix Title:')]/following-sibling::p"))).text self.proj_idea_proj_title_normalized = self.proj_idea_proj_title.lower() print('unit name is', self.expected_name, 'and proj idea name is', self.proj_idea_proj_title_normalized, 'and they\'re a match:', self.expected_name == self.proj_idea_proj_title_normalized) self.assertEqual(self.expected_name, self.proj_idea_proj_title_normalized) @allure.step('tflx open show what you know') def test_open_show_what_you_know(self): self.cat, self.unit = self.tflx_login_rand_cat_rand_unit() self.expected_img_src = '/limelight/images/core/headers/show_know.png' self.tflx_click_show_know() self.show_know_img = WebDriverWait(self.driver.instance, 10).until( EC.visibility_of_element_located((By.XPATH, ".//div[@id='headingImage_content']/img"))) self.show_know_img_src_attrib = self.show_know_img.get_attribute('src') print('show know img src is', self.show_know_img_src_attrib) assert self.show_know_img.is_displayed() self.assertIn(self.expected_img_src, self.show_know_img_src_attrib) def tearDown(self): self.driver.instance.quit()
class TestQABoy(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.navigate(config.base_url) self.driver.instance.maximize_window() @allure.story('Story# 1') @allure.testcase("Test1") def test_home_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.validate_title_is_present() home_screen.validate_icon_is_present() home_screen.validate_menu_options_are_present() home_screen.validate_posts_are_visible() home_screen.validate_social_media_links() # @allure.testcase("Test2") def test_about_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.click_about_me_link() about_screen = AboutScreen(self.driver) about_screen.validate_title_is_present() about_screen.validate_icon_is_present() about_screen.validate_menu_options_are_present() about_screen.validate_social_media_links() about_screen.validate_about_me_header() about_screen.validate_about_me_post() @allure.testcase("Test3") def test_post_screen_components(self): home_screen = HomeScreen(self.driver) home_screen.click_first_post() post_screen = PostScreen(self.driver) post_screen.validate_title_is_present() post_screen.validate_icon_is_present() post_screen.validate_menu_options_are_present() post_screen.validate_social_media_links() post_screen.validate_featured_image() post_screen.validate_published_date() post_screen.validate_share_buttons() post_screen.validate_comment_section() @allure.testcase("Test4") def test_search_for_article(self): sidebar = SideBar(self.driver) sidebar.search_for_article(config.article_title) search_screen = SearchScreen(self.driver) search_screen.click_article(config.article_title) post_screen = PostScreen(self.driver) post_screen.validate_article_title(config.article_title) @allure.testcase("Test5") def test_check_user_comment(self): sidebar = SideBar(self.driver) sidebar.click_user_comment() post_screen = PostScreen(self.driver) post_screen.validate_comment_section() # @allure.testcase("Test6") # def test_archived_articles(self): # sidebar = SideBar(self.driver) # sidebar.click_archive() @allure.testcase("Test7") def test_article_categories(self): sidebar = SideBar(self.driver) sidebar.click_category() def tearDown(self): self.driver.instance.close() self.driver.instance.quit()