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 AddToGroup(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.get(strings.Urls.editor_url) self.driver.add_cookie( strings.Cookies.editor_test_blog_password_cookie) @capture_screenshot def test_edit_existing_article(self): login_screen = LoginScreen(self.driver) login_screen.login(strings.LoginCredentials.editorUsername, strings.LoginCredentials.editorPassword) editor_dashboard = EditorDashboard(self.driver) editor_dashboard.search_for_article("Editable Article (DO NOT DELETE)") editor_dashboard.click_existing_article( "Editable Article (DO NOT DELETE)") compose_tab = ComposeTab(self.driver) updated_text = compose_tab.add_new_story_content("THIS IS AN EDIT. ") editor_dashboard.saved() compose_tab.click_finalize() finalize_tab = FinalizeTab(self.driver) editor_dashboard.saved() finalize_tab.click_publish_changes() finalize_tab.click_confirm_publish_changes() editor_dashboard.view_published_entry("story") published_entry = PublishedEntry(self.driver) published_entry.body_text_present(updated_text) def tearDown(self): self.driver.instance.quit()
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()
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()
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()
def step_impl_validate_logged_in(context): """ :type context: behave.runner.Context """ driver = Driver() loginpage = LoginPage(driver) driver = loginpage.log_in() context.adsdesignpage = AdDesignPage(driver)
def step_impl_open_login_page(context): """ :type context: behave.runner.Context """ context.driver = Driver() context.loginpage = LoginPage(context.driver) context.loginpage.load_login_page() context.loginpage.verify_on_login_page()
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()
def step_impl(context): """ :type context: behave.runner.Context """ driver = Driver() loginpage = LoginPage(driver) driver = loginpage.log_in() context.adsdesignpage = AdDesignPage(driver) context.adsdesignpage.click_menu() context.adsdesignpage.verify_on_ad_design_page()
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()
def step_impl(context): """ :type context: behave.runner.Context """ is_headless = context.config.userdata.get("headless", None) driver = Driver(is_headless) loginpage = LoginPage(driver) driver = loginpage.log_in() context.navmenu = NavigationMenu(driver) context.adsdesignpage = AdDesignPage(driver) context.navmenu.navigate_to_page("Ad Designs") context.adsdesignpage.verify_on_ad_design_page()
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()
def step_impl(context): """ :type context: behave.runner.Context """ is_headless = context.config.userdata.get("headless", None) driver = Driver(is_headless) loginpage = LoginPage(driver) driver = loginpage.log_in() context.navmenu = NavigationMenu(driver) context.audiencepage = AudiencePage(driver) context.navmenu.navigate_to_page("Audience") context.audiencepage.verify_on_audiences_page() context.audiencepage.verify_audiences_page_is_paginated()
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 AddBodyGallery(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.get(strings.Urls.editor_url) self.driver.add_cookie( strings.Cookies.editor_test_blog_password_cookie) @capture_screenshot def test_add_body_gallery(self): login_screen = LoginScreen(self.driver) login_screen.login(strings.LoginCredentials.editorUsername, strings.LoginCredentials.editorPassword) editor_dashboard = EditorDashboard(self.driver) editor_dashboard.create_new_story() compose_tab = ComposeTab(self.driver) compose_tab.type_headline("Article Headline") compose_tab.type_dek("Article Dek") compose_tab.click_insert_dropdown_item("Gallery") add_gallery_modal = ComposeTab.AddGalleryModal(self.driver) add_gallery_modal.click_new_gallery() create_gallery_menu = ComposeTab.CreateGalleryMenu(self.driver) create_gallery_menu.enter_gallery_title("Article Gallery") create_gallery_menu.click_gallery_image_dropdown() create_gallery_menu.upload_gallery_images("assets/ah-jpg.jpg", "assets/dc-ah-banner.jpg") create_gallery_menu.click_insert_gallery() compose_tab.body_item_displayed("gallery") editor_dashboard.saved() compose_tab.click_finalize() finalize_tab = FinalizeTab(self.driver) finalize_tab.click_publish_button() finalize_tab.click_confirm_publish_now() editor_dashboard.view_published_entry("story") published_entry = PublishedEntry(self.driver) published_entry.body_gallery_displayed() 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 CreateNewStory(unittest.TestCase): def setUp(self): self.driver = Driver() self.driver.get(strings.Urls.editor_url) self.driver.add_cookie( strings.Cookies.editor_test_blog_password_cookie) @capture_screenshot def test_create_new_story(self): login_screen = LoginScreen(self.driver) login_screen.login(strings.LoginCredentials.editorUsername, strings.LoginCredentials.editorPassword) editor_dashboard = EditorDashboard(self.driver) editor_dashboard.create_new_story() compose_tab = ComposeTab(self.driver) compose_tab.type_headline("Article Headline") compose_tab.type_dek("Article Dek") compose_tab.click_select_art() lead_art_dropdown = ComposeTab.LeadArtDropdown(self.driver) lead_art_dropdown.upload_lead_art("assets/ah-jpg.jpg") add_image_modal = ComposeTab.AddImageModal(self.driver) add_image_modal.click_insert_image() compose_tab.add_story_content("This is the first line of a story.") editor_dashboard.saved() compose_tab.click_finalize() finalize_tab = FinalizeTab(self.driver) editor_dashboard.saved() finalize_tab.click_publish_button() finalize_tab.click_confirm_publish_now() editor_dashboard.view_published_entry("story") published_entry = PublishedEntry(self.driver) published_entry.story_items_displayed( "Article Headline", "Article Dek", "This is the first line of a story.") def tearDown(self): self.driver.instance.quit()
def step_impl(context, screen_name): """ :type screen_name: str :type context: behave.runner.Context """ driver = Driver() loginpage = LoginPage(driver) driver = loginpage.log_in() context.adsdesignpage = AdDesignPage(driver) context.adsdesignpage.click_menu() context.adsdesignpage.verify_on_ad_design_page() context.adsdesignpage.click_create_ad_design_button() context.adsdesignpage.click_box("pagePostAd") context.adsdesignpage.click_btn("Next") context.adsdesignpage.screen_is_displayed(screen_name)
def step_impl(context, adtype_id): """ :type adtype_id: str :type context: behave.runner.Context """ is_headless = context.config.userdata.get("headless", None) driver = Driver(is_headless) loginpage = LoginPage(driver) driver = loginpage.log_in() context.navmenu = NavigationMenu(driver) context.adsdesignpage = AdDesignPage(driver) context.navmenu.navigate_to_page("Ad Designs") context.adsdesignpage.verify_on_ad_design_page() context.adsdesignpage.click_create_ad_design_button() if adtype_id == 'leadAd': context.adsdesignpage.select_page('Test page') context.adsdesignpage.click_box(adtype_id) context.adsdesignpage.click_btn("Next") context.ad_type = adtype_id + "Type" context.adsdesignpage.screen_is_displayed(context.ad_type) context.popup_window = PopUpWindow(driver) context.design_count = context.adsdesignpage._get_design_count()
# -*- coding: utf-8 -*- # 主函数入口文件 import random from pageobjects import Login, Controller from webdriver import Driver from logger import Logger # 列表中列出测试页面,以逗号分隔,文稿名称用单引号引着 doc_list = ['日常接待版-稳定性测试', '社会治理平台-稳定性测试'] # 初始化驱动 driver = Driver().driver # 初始化日志 logger = Logger().get_logger() # 登录 login = Login(driver) login.login() # 初始化操作控制器 controller = Controller(driver) # 选择显示屏 controller.select_screen() # 死循环去播放文稿的页面 while True: for _ in range(3): play_doc = random.choice(doc_list) result = controller.choice_doc(play_doc) if result is False: continue controller.start() controller.loop_play()
def setUp(self): self.driver = Driver() self.driver.navigate(strings.base_url)
from webdriver import Driver import time import os import logging driver = Driver() driver.setAutoClose() url = "https://www.cnblogs.com/" driver.open_browser(url) driver.scrollToBootom()
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()
import os from webdriver import Driver import logging logging.basicConfig(filename='logs', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') driver = Driver.Driver('D:\Downloads\Chrome', True).driver class AnimesVisionBot: def list_animes(self): print('.: Downaload no Animes Vision :.') print('Digite o termo para a pesquisa') while True: try: print('>>', end=' ') key = str(input()) break except: print('<< Invalido') continue logging.info('Pesquisando ' + key) try: driver.get('https://animesvision.biz/search?query=' + key) animes = driver.find_elements_by_class_name('thumb') if len(animes) == 0: print('Nenhum resultado para a sua busca :(') except: logging.info('Elemnto não encontrado') return animes
def setUp(self): self.driver = Driver() self.driver.instance.maximize_window() self.driver.navigate(strings.base_url)