def testShouldCheckAddonDeactivateAndActivate(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) addonpage_obj = AddonEditorPage(mozwebqa) homepage_obj.go_to_home_page() homepage_obj.header.click_signin() loginpage_obj.login() Assert.true(dashboardpage_obj.is_the_current_page) # Go back to homepage and create a new addon to work with. dashboardpage_obj.header.click_home_logo() homepage_obj.click_create_addon_btn() addon_name = addonpage_obj.addon_name addonpage_obj.header.click_dashboard() #Click on the private button to make it private and then check that the addon is not in the list anymore dashboardpage_obj.addon(addon_name).click_private() Assert.false(dashboardpage_obj.addon(addon_name).is_displayed, "Addon %s found" % addon_name) #Go to the private addons page and check that the addon that you just made private is present there. #Click on public to make it public and check on the dashboard that the addon is present there. dashboardpage_obj.click_private_addons_link() Assert.true(dashboardpage_obj.addon(addon_name).is_displayed, "Addon %s not found" % addon_name) # Switch it back to public now, addon should disappear dashboardpage_obj.addon(addon_name).click_public() Assert.false(dashboardpage_obj.addon(addon_name).is_displayed, "Addon %s found" % addon_name) # Should be on main dashboard page dashboardpage_obj.header.click_dashboard() Assert.true(dashboardpage_obj.addon(addon_name).is_displayed, "Addon %s not found" % addon_name) dashboardpage_obj.delete_test_data()
def testShouldCheckLibDeactivateAndActivate(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) librarypage_obj = LibraryEditorPage(mozwebqa) homepage_obj.go_to_home_page() homepage_obj.header.click_signin() loginpage_obj.login() Assert.true(dashboardpage_obj.is_the_current_page) # go back to homepage, create a new library to work with dashboardpage_obj.header.click_home_logo() homepage_obj.click_create_lib_btn() library_name = librarypage_obj.library_name librarypage_obj.header.click_dashboard() #Click on the private button to make it private and then check that the library is not in the list anymore dashboardpage_obj.library(library_name).click_private() Assert.false(dashboardpage_obj.library(library_name).is_displayed, "Library %s found" % library_name) #Go to the private libraries page and check that the library that you just made private is present there. #Click on public to make it public and check on the dashboard that the library is present there. dashboardpage_obj.click_private_libraries_link() Assert.true(dashboardpage_obj.library(library_name).is_displayed, "Library %s not found" % library_name) # Switch it back to public - it should disappaer dashboardpage_obj.library(library_name).click_public() Assert.false(dashboardpage_obj.library(library_name).is_displayed, "Library %s found" % library_name) # Go to main dashboard, should be present dashboardpage_obj.header.click_dashboard() Assert.true(dashboardpage_obj.library(library_name).is_displayed, "Library %s not found" % library_name) dashboardpage_obj.delete_test_data()
def testShouldCheckAddonLabel(self, mozwebqa): #This test is to check the labels of an add-on on the dashboard #Create page objects homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) addonpage_obj = AddonEditorPage(mozwebqa) loginpage_obj.login() #Create an addon. Then go to dashboard and assert that the label is 'initial'. homepage_obj.go_to_home_page() homepage_obj.click_create_addon_btn() addon_name = addonpage_obj.addon_name homepage_obj.header.click_dashboard() Assert.true(dashboardpage_obj.is_the_current_page) Assert.true(dashboardpage_obj.addon(addon_name).is_displayed, "Addon %s not found" % addon_name) #Click on the edit button of the addon.Then create a copy of that addon and assert that the label is 'copy' dashboardpage_obj.addon(addon_name).click_edit() addonpage_obj.click_copy() copy_addon_name = addonpage_obj.addon_name try: Assert.not_equal(addon_name, copy_addon_name) except: print 'A copy of the addon could not be created' homepage_obj.header.click_dashboard() Assert.true(dashboardpage_obj.addon(copy_addon_name).is_displayed, "Addon %s not found" % copy_addon_name) dashboardpage_obj.delete_test_data()
def testShouldCheckLibraryLabel(self, mozwebqa): #This test is to check the labels of a library on the dashboard #Create page objects homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) libpage_obj = LibraryEditorPage(mozwebqa) loginpage_obj.login() #Create a library. Then go to dashboard and assert that the label is present. homepage_obj.go_to_home_page() homepage_obj.click_create_lib_btn() library_name = libpage_obj.library_name libpage_obj.header.click_dashboard() Assert.true(dashboardpage_obj.is_the_current_page) Assert.true(dashboardpage_obj.library(library_name).is_displayed, "Library %s not found" % library_name) #Click on the edit button of the library.Then create a copy of that library and assert that the label is 'copy' dashboardpage_obj.library(library_name).click_edit() libpage_obj.click_copy() copy_library_name = libpage_obj.library_name try: Assert.not_equal(library_name, copy_library_name) except: print 'A copy of the library could not be created' libpage_obj.header.click_dashboard() Assert.true(dashboardpage_obj.library(copy_library_name).is_displayed, "Library %s not found" % copy_library_name) dashboardpage_obj.delete_test_data()
def setUp(self): self.driver = webdriver.Firefox() self.driver.maximize_window() self.driver.get(self.generalProp["url"]) login = LoginPage(self.driver) assert login.check_login_page()
def test_search_by_library_name_returns_library(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboard_obj = DashboardPage(mozwebqa) librarypage_obj = LibraryEditorPage(mozwebqa) searchpage_obj = SearchPage(mozwebqa) homepage_obj.go_to_home_page() homepage_obj.header.click_signin() loginpage_obj.login() #create a new library with the valid criteria (version not initial) dashboard_obj.header.click_home_logo() homepage_obj.click_create_lib_btn() librarypage_obj.type_library_version('searchable') librarypage_obj.click_save() searchterm = librarypage_obj.library_name librarypage_obj.header.click_home_logo() homepage_obj.header.click_search() searchpage_obj.search_until_package_exists(searchterm, searchpage_obj.library(searchterm)) Assert.true(searchpage_obj.library(searchterm).is_displayed, '%s not found before timeout' % searchterm) searchpage_obj.delete_test_data()
def test_logout(self, mozwebqa): loginpage_obj = LoginPage(mozwebqa) dashboard_obj = loginpage_obj.login() Assert.true(dashboard_obj.header.logged_in) homepage_obj = dashboard_obj.header.click_signout() Assert.true(homepage_obj.header.logged_out)
def test_login(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboard_obj = DashboardPage(mozwebqa) homepage_obj.go_to_home_page() homepage_obj.header.click_signin() Assert.true(loginpage_obj.is_the_current_page) loginpage_obj.login() Assert.true(dashboard_obj.is_the_current_page) Assert.true(dashboard_obj.header.logged_in) Assert.equal(dashboard_obj.logged_in_username, mozwebqa.credentials['default']['name'])
def setUp(self): profile = webdriver.FirefoxProfile() profile.set_preference('browser.download.folderList', 2) profile.set_preference('browser.download.manager.showWhenStarting', False) profile.set_preference("browser.download.dir", os.getcwd()) profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/xml') self.driver = webdriver.Firefox(profile) self.driver.maximize_window() self.driver.implicitly_wait(20) login_page = LoginPage(self.driver) login_page.navigate() self.current_view = login_page.login(LOGIN, PASS)
def test_clicking_library_source_displays_editor(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboard_obj = DashboardPage(mozwebqa) searchpage_obj = SearchPage(mozwebqa) editorpage_obj = LibraryEditorPage(mozwebqa) homepage_obj.go_to_home_page() homepage_obj.header.click_signin() loginpage_obj.login() dashboard_obj.header.click_search() library_name = searchpage_obj.library(1).name searchpage_obj.library(library_name).click() Assert.equal(editorpage_obj.library_name, library_name) searchpage_obj.delete_test_data()
def testShouldCheckLibDelete(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) libpage_obj = LibraryEditorPage(mozwebqa) homepage_obj.go_to_home_page() loginpage_obj.login() homepage_obj.go_to_home_page() homepage_obj.click_create_lib_btn() library_name = libpage_obj.library_name homepage_obj.header.click_dashboard() dashboardpage_obj.library(library_name).click_delete() dashboardpage_obj.library(library_name).confirm_delete() Assert.false(dashboardpage_obj.library(library_name).is_displayed, "Library %s found" % library_name)
def testShouldCheckAddonDelete(self, mozwebqa): homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) addonpage_obj = AddonEditorPage(mozwebqa) loginpage_obj.login() homepage_obj.go_to_home_page() homepage_obj.click_create_addon_btn() # Get the name of the addon on the editor page. addon_name = addonpage_obj.addon_name # Go the the dashboard and delete the addon that you just created. Then check that the addon at the top of the list is not the same as the one you just deleted. homepage_obj.header.click_dashboard() dashboardpage_obj.addon(addon_name).click_delete() dashboardpage_obj.addon(addon_name).confirm_delete() Assert.false(dashboardpage_obj.addon(addon_name).is_displayed, "Addon %s found" % addon_name)
def testAddonCount(self, mozwebqa): #This test is to assert that the count of the addons on dashboard is equal to the number of addons present on the page. #Create page objects homepage_obj = HomePage(mozwebqa) loginpage_obj = LoginPage(mozwebqa) dashboardpage_obj = DashboardPage(mozwebqa) homepage_obj.go_to_home_page() homepage_obj.header.click_signin() loginpage_obj.login() Assert.true(dashboardpage_obj.is_the_current_page) #Get the total count of the number of add-ons that are displayed on the dashboard. addon_count = dashboardpage_obj.addons_element_count() #Get the number of addons that are displayed on the left hand side of the page.(Something like your add-ons(20)) counter = dashboardpage_obj.addons_count_label #Assert that the total addons on the page matches the counter on the left hand side. Assert.equal(str(addon_count), str(counter))
def setUp(self): """ Initialize all page objects """ super(TestAddNotifications, self).setUp() self.browser.maximize_window() self.home_page = HomePage(self.browser) self.registration_page = RegistrationPage(self.browser) self.registration_success = RegistrationSuccess(self.browser) self.login_page = LoginPage(self.browser) self.logged_in_home_page = LoggedInHomePage(self.browser) self.notification_target_page = NotificationTargetPage(self.browser)
def test_login_cloud_server(self): username = self.generalProp["user"] password = self.generalProp["pass"] login = LoginPage(self.driver) vra = PortalVra(self.driver) # Login login.type_user_name(username) login.type_user_pass(password) login.click_on_send() # Close tour dialog is displayed #dashboard.close_tour_dialog() # I'm in dashboard page assert vra.check_vra_page() # Logout vra.logout()
def __init__(self, driver, base_url): self.driver = driver driver.get(base_url) driver.maximize_window() self.wait = WebDriverWait(driver, 15) self.login_page = LoginPage(driver, base_url) self.persons_page = PersonsPage(driver, base_url) self.internal_page = InternalPage(driver, base_url) self.person_main_page = AddPersonMainPage(driver, base_url) self.enrollments_page = EnrollmentsPage(driver, base_url) self.dictionaries_page = DictionariesPage(driver, base_url) self.person_current_view_page = PersonCurrentViewPage(driver, base_url) self.person_main_view_page = PersonMainViewPage(driver, base_url) self.person_papers_view_page = PersonPapersViewPage(driver, base_url) self.person_enrollment_view_page = PersonEnrollmentViewPage(driver, base_url) self.enrollments_main_page = EnrollmentsMainPage(driver, base_url) self.enrollments_base_page = EnrollmentsBasePage(driver, base_url) self.main_page = AddPersonMainPage(driver, base_url) self.extra_page = AddPersonExtraPage(driver, base_url) self.address_page = AddPersonAddressesPage(driver, base_url) self.contact_page = AddPersonContactsPage(driver, base_url) self.papers_page = AddPersonPapersPage(driver, base_url) self.person_base_page = AddPersonPage(driver, base_url) self.person_enrollment = PersonEnrollmentPage(driver, base_url)
def ClassSetup(self, BrowserSetUp): self.loginPage = LoginPage(self.driver) yield self.driver.quit()
class TestAddNotifications(WebAppTest): notification_dict = { 'open-edx.studio.announcements.new-announcement': 'Gettysburg Address', 'open-edx.lms.discussions.reply-to-thread': 'testuser responded to your post in ', 'open-edx.lms.discussions.thread-followed': 'A demo posting to the discussion forums was followed 3 times', 'open-edx.lms.discussions.post-upvoted': 'post A demo posting to the discussion forums was upvoted 5 times', 'open-edx.lms.discussions.cohorted-thread-added': 'testuser posted: Four score and seven years ago', 'open-edx.lms.discussions.cohorted-comment-added': 'testuser responded: Four score and seven years ago', 'open-edx.lms.discussions.comment-upvoted': 'response to A demo posting to the discussion forums was upvoted', 'open-edx.lms.leaderboard.progress.rank-changed': 'You are now #2 for Progress in the cohort!', 'open-edx.lms.leaderboard.gradebook.rank-changed': 'You are now #3 for Proficiency in the cohort!', 'open-edx.lms.leaderboard.engagement.rank-changed': 'You are now #1 for Engagement in the cohort!', 'open-edx.xblock.group-project.file-uploaded': 'First Activity: testuser uploaded a file', 'open-edx.xblock.group-project.stage-open': 'First Activity: Upload(s) are open', 'open-edx.xblock.group-project.stage-due': 'First Activity: Upload(s) due 4/25', 'open-edx.xblock.group-project.grades-posted': 'First Activity: Grade(s) are posted', } short_notification_dict = { 'open-edx.studio.announcements.new-announcement': 'Gettysburg Address', 'open-edx.lms.discussions.reply-to-thread': 'testuser responded to your post in ', 'open-edx.lms.discussions.cohorted-thread-added': 'testuser posted: Four score and seven years ago', 'open-edx.lms.leaderboard.progress.rank-changed': 'You are now #2 for Progress in the cohort!', 'open-edx.xblock.group-project.grades-posted': 'First Activity: Grade(s) are posted', } if HIDE_LINK_IS_VISIBLE: notifications_container_tabs = ['View unread', 'View all', 'Mark as read', 'Hide', 'Settings'] else: notifications_container_tabs = ['View unread', 'View all', 'Mark as read', 'Settings'] namespaces = ['foo/bar/baz', 'test/test/test'] def setUp(self): """ Initialize all page objects """ super(TestAddNotifications, self).setUp() self.browser.maximize_window() self.home_page = HomePage(self.browser) self.registration_page = RegistrationPage(self.browser) self.registration_success = RegistrationSuccess(self.browser) self.login_page = LoginPage(self.browser) self.logged_in_home_page = LoggedInHomePage(self.browser) self.notification_target_page = NotificationTargetPage(self.browser) def test_00_show_notification_pane(self): """ Scenario: User is able to show the notification container Given that I am on the notification home page And notifications container is hidden When I click the notification icon Then I should see the notification container When I click on the hide link Then notification container becomes invisible again """ self.login() self.logged_in_home_page.verify_notifications_container_is_invisible() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() def test_01_hide_notification_pane(self): """ Scenario: User is able to hide the notification container Given that I am on the notification home page And notifications container is visible When I click on the notification icon again Then notification container should hide """ self.login() self.logged_in_home_page.verify_notifications_container_is_invisible() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() @skipUnless(HIDE_LINK_IS_VISIBLE, "Test only runs if Hide link is visible") def test_02_hide_link(self): """ Scenario: User is able to hide the notification container using hide link Given that I am on the notification home page And notifications container is visible When I click on the notification icon again Then notification container should hide """ self.login() self.logged_in_home_page.verify_notifications_container_is_invisible() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.hide_notification_container_using_hide_link() self.logged_in_home_page.verify_notifications_container_is_invisible() def test_03_verify_tabs(self): """ Scenario: User is able to view 4 tabs namely view unread, view all, Mark as read and hide in notification container Given that I am on the notification home page And notifications container is hidden When I click the notification icon Then I should see the notification container And notification container should display 4 tabs(unread, view all, Mark as read, Hide) """ self.login() self.logged_in_home_page.verify_notifications_container_is_invisible() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() fetched_notifications_container_tabs = self.logged_in_home_page.return_notifications_container_tabs() self.assertEqual(fetched_notifications_container_tabs, self.notifications_container_tabs) def test_04_verify_default_tab(self): """ Scenario: When notification container becomes visible, by default the View Unread tab is selected Given that I am on the notification home page And notifications container is hidden When I click the notification icon Then I should see the notification container And by default the View Unread tab should be selected """ self.login() self.logged_in_home_page.verify_notifications_container_is_invisible() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() fetched_selected_tab = self.logged_in_home_page.return_selected_tab() self.assertEqual(fetched_selected_tab, self.notifications_container_tabs[0]) def test_05_unread_notifications_count(self): """ Scenario: Clicking on the add notification button after selecting a notification type increases the unread notification count by 1. Given that I am on the notification home page When I click the notification icon after adding a notification Then I should see the increase in unread notification count by 1 """ self.login() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() initial_unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() for key in self.notification_dict: self.logged_in_home_page.select_notification_type(key) self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() final_unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() self.assertEqual(final_unread_notification_count, initial_unread_notification_count + 1) initial_unread_notification_count = final_unread_notification_count def test_06_view_all_notification_count(self): """ Scenario: Clicking on the add notification button after selecting a notification type increases the notification count in view all tab by 1. Given that I am on the notification home page When I click the notification icon after adding a notification Then I should see the increase in notification count by 1 in view all tab """ self.login() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.select_view_all_tab() initial_notification_count = self.logged_in_home_page.return_view_all_notifications_count() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() for key in self.short_notification_dict: self.logged_in_home_page.select_notification_type(key) self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.select_view_all_tab() final_notification_count = self.logged_in_home_page.return_view_all_notifications_count() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() self.assertEqual(final_notification_count, initial_notification_count + 1) initial_notification_count = final_notification_count def test_07_unread_notifications_text(self): """ Scenario: When user adds a new notification type, the relevant message for this notification type appears in unread notifications tab Given that I am on the notification home page And notifications container is hidden When I add a specific notification type And click the notification icon Then I should see the unread notifications And a relevant message for the added notification type should be visible in unread notification tab """ self.login() for key, value in self.notification_dict.iteritems(): self.logged_in_home_page.select_notification_type(key) self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() unread_notification_list = self.logged_in_home_page.return_notifications_list(key) self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() self.assertIn(value, unread_notification_list[0]) def test_08_view_all_notifications_text(self): """ Scenario: When user adds a new notification type, the relevant message for this notification type appears in view all notifications tab Given that I am on the notification home page And notifications container is hidden When I add a specific notification type And click the notification icon Then I should see the unread notifications And a relevant message for the added notification type should be visible in view all notification tab """ self.login() for key, value in self.short_notification_dict.iteritems(): self.logged_in_home_page.select_notification_type(key) self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.select_view_all_tab() notification_list = self.logged_in_home_page.return_notifications_list(key) self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() self.assertIn(value, notification_list[0]) def test_09_mark_as_read(self): """ Scenario: When user clicks on mark as read tab, notifications disappear from unread notifications tab Given that I am on the notification home page And there are some notifications present in unread notification tab When I click on mark as read link Then all notifications should disappear from unread notifications tab And notification count on panel should also become 0 """ self.login() self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.assertTrue(unread_notification_count > 0) self.logged_in_home_page.mark_as_read() unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.assertEqual(unread_notification_count, 0) display_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(display_notification_count, 0) def test_10_page_redirect(self): """ Scenario: When user clicks on any notification, it should redirect user to a specific page Given that I am on the notification home page And there are some notifications present When I click on any notification Then it should redirect me to a specific page And the resulting page url should be same as click link """ for key in self.notification_dict: if key != 'testserver.type1': self.login() self.logged_in_home_page.select_notification_type(key) self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() notification_link = self.logged_in_home_page.click_on_notification() self.notification_target_page.verify_target_page_url(notification_link) self.browser.back() self.logged_in_home_page.log_out() def test_11_page_refresh(self): """ Scenario: When user clicks on any notification without target link, it should just refresh the page Given that I am on the notification home page And there are some notifications present When I click on any notification Then it should just refresh the page """ self.login() self.logged_in_home_page.select_notification_type('testserver.type1') self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() notification_link = self.logged_in_home_page.click_on_notification() self.assertEqual(notification_link, 'No target link') def test_12_status_change_one(self): """ Scenario: When user clicks on any unread notification, it should change it's status to read When I click on any unread notification Then it's status should change to unread """ self.login() self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.logged_in_home_page.click_on_notification() self.browser.back() self.logged_in_home_page.log_out() self.login() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() new_unread_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(new_unread_notification_count, unread_notification_count - 1) def test_13_status_change_two(self): """ Scenario: When user clicks on any notification without target link, it should change it's status to read When I click on any unread notification Then it's status should change to unread """ self.login() self.logged_in_home_page.select_notification_type('testserver.type1') self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.logged_in_home_page.click_on_notification() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() new_unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.assertEqual(new_unread_notification_count, unread_notification_count - 1) def test_14_notification_count_decrease_one(self): """ Scenario: When user clicks on any notification, the notification count should decrease by 1 Given that I am on the notification home page And there are some notifications present When I click on any unread notification Then it the main notification count should be decreased by 1 """ self.login() self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() notification_count = self.logged_in_home_page.get_notifications_count() self.logged_in_home_page.click_on_notification() self.browser.back() self.logged_in_home_page.log_out() self.login() new_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(new_notification_count, notification_count - 1) def test_15_notification_count_decreases_two(self): """ Scenario: When user clicks on any notification without target link, the notification count should decrease by 1 Given that I am on the notification home page And there are some notifications present When I click on any unread notification Then it the main notification count should be decreased by 1 """ self.login() self.logged_in_home_page.select_notification_type('testserver.type1') self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() notification_count = self.logged_in_home_page.get_notifications_count() self.logged_in_home_page.click_on_notification() new_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(new_notification_count, notification_count - 1) def test_16_namespace_one(self): """ Scenario: When user adds notification in first namespace, it does not change notification count in 2nd namespace Given that I am on the notification home page And all name spaces have been initialized to 0 count When I add notifications in any namespace Then the notification count in other namespace remains unchanged """ self.login() for namespace in self.namespaces: self.logged_in_home_page.set_namespace(namespace) self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.mark_as_read() display_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(display_notification_count, 0) self.logged_in_home_page.set_namespace(self.namespaces[0]) self.logged_in_home_page.add_notification() notification_count_for_namespace_1 = self.logged_in_home_page.get_notifications_count() self.assertEqual(notification_count_for_namespace_1, 1) self.logged_in_home_page.set_namespace(self.namespaces[1]) notification_count_for_namespace_2 = self.logged_in_home_page.get_notifications_count() self.assertEqual(notification_count_for_namespace_2, 0) def test_18_namespace_two(self): """ Scenario: When user adds notification in first namespace, it does not change unread notification count in other namespace Given that I am on the notification home page And all name spaces have been initialized to 0 count When I add notifications in any namespace Then the unread notification count in other namespace remains unchanged """ self.login() for namespace in self.namespaces: self.logged_in_home_page.set_namespace(namespace) self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.mark_as_read() display_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(display_notification_count, 0) self.logged_in_home_page.set_namespace(self.namespaces[1]) self.logged_in_home_page.add_notification() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() unread_notification_count_for_namespace_2 = self.logged_in_home_page.return_unread_notifications_count() self.assertEqual(unread_notification_count_for_namespace_2, 1) self.logged_in_home_page.set_namespace(self.namespaces[0]) self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() unread_notification_count_for_namespace_1 = self.logged_in_home_page.return_unread_notifications_count() self.assertEqual(unread_notification_count_for_namespace_1, 0) def test_19_namespace_three(self): """ Scenario: When user marks notifications in first namespace as read, it does not change notifications status in 2nd namespace Given that I am on the notification home page And all name spaces have some notifications When I mark notifications as read in one name space Then the notification status in other namespace remains unchanged """ self.login() for namespace in self.namespaces: self.logged_in_home_page.set_namespace(namespace) self.logged_in_home_page.add_notification() self.logged_in_home_page.set_namespace(self.namespaces[0]) self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.mark_as_read() notification_count_for_namespace_1 = self.logged_in_home_page.get_notifications_count() self.assertEqual(notification_count_for_namespace_1, 0) self.logged_in_home_page.set_namespace(self.namespaces[1]) notification_count_for_namespace_2 = self.logged_in_home_page.get_notifications_count() self.assertTrue(notification_count_for_namespace_2 > 0) def test_20_close_icon(self): """ Scenario: When user clicks on close icon of any notification, it should remain on current page and notification count along with unread count should decrease by 1 Given that I am on the notification home page And there are some notifications present When I click on any notification's close icon Then it should stay on the same page And the notification count should decrease by one And unread notification count should also decrease by one """ self.login() self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.mark_as_read() self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() for key in self.notification_dict: self.logged_in_home_page.select_notification_type(key) self.logged_in_home_page.add_notification() initial_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(initial_notification_count, 1) self.logged_in_home_page.show_notifications_container() self.logged_in_home_page.verify_notifications_container_is_visible() initial_unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.assertEqual(initial_unread_notification_count, 1) self.logged_in_home_page.verify_notifications_container_is_visible() self.logged_in_home_page.close_notification() self.assertTrue(self.logged_in_home_page.is_browser_on_page()) final_unread_notification_count = self.logged_in_home_page.return_unread_notifications_count() self.assertEqual(final_unread_notification_count, 0) final_notification_count = self.logged_in_home_page.get_notifications_count() self.assertEqual(final_notification_count, 0) self.logged_in_home_page.hide_notification_container() self.logged_in_home_page.verify_notifications_container_is_invisible() def login(self): """ Go to home page and login using correct credentials """ self.home_page.visit() self.home_page.go_to_login_page() login_result = self.login_page.login_to_application(user_name, password) if login_result == 'User not registered': self.home_page.go_to_registration_page() self.registration_page.register(user_name, user_email, password) self.registration_success.go_to_login_page() self.login_page.login_to_application(user_name, password) self.assertTrue(self.logged_in_home_page.is_browser_on_page()) self.assertTrue(self.logged_in_home_page.is_browser_on_page())
def setUp(self): self.driver.implicitly_wait(20) login_page = LoginPage(self.driver) login_page.navigate() login_page.do_login(LOGIN, PASS)
class EmergencyContactsTestCase(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome(executable_path=CHROME_EXECUTABLE_PATH) self.driver.get(DOMAIN) self.wait = WebDriverWait(self.driver, 2) self.login_page = LoginPage(self.driver) self.personal_details_page = PersonalDetailsPage(self.driver) self.add_photograph_page = AddPhotographPage(self.driver) self.contact_details_page = ContactDetailsPage(self.driver) self.emergency_contacts_page = EmergencyContactsPage(self.driver) def tearDown(self): self.driver.quit() def test_16_add_emergency_contacts(self): name = 'Emer' relationship = 'wife' home_phone = '123456789' mobile_phone = '987654321' work_phone = '123366654' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.set_mobile_phone(mobile_phone) self.emergency_contacts_page.set_work_phone(work_phone) self.emergency_contacts_page.save_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) table_name = self.driver.find_element_by_xpath( '//*[@id="emgcontact_list"]/tbody/tr[1]/td[2]/a') self.assertTrue(table_name.text == name) # deleting created emergency contact self.driver.find_element_by_css_selector("td>input").click() self.driver.find_element_by_id("delContactsBtn").click() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Deleted')) def test_17_emergency_name_requered(self): driver = self.driver relationship = 'wife' home_phone = '123456789' mobile_phone = '987654321' work_phone = '123366654' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.set_mobile_phone(mobile_phone) self.emergency_contacts_page.set_work_phone(work_phone) self.emergency_contacts_page.save_button() self.assertTrue( driver.find_element_by_xpath( '//*[@id="frmEmpEmgContact"]/fieldset/ol/li[1]/span').text == 'Required') def test_18_emergency_relationship_requered(self): driver = self.driver name = 'Emer' home_phone = '123456789' mobile_phone = '987654321' work_phone = '123366654' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.set_mobile_phone(mobile_phone) self.emergency_contacts_page.set_work_phone(work_phone) self.emergency_contacts_page.save_button() self.assertTrue( driver.find_element_by_xpath( '//*[@id="frmEmpEmgContact"]/fieldset/ol/li[2]/span').text == 'Required') def test_19_emergency_one_phone_enough(self): name = 'Emer' relationship = 'wife' home_phone = '123456789' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.save_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) def test_20_emergency_one_phone_requered(self): driver = self.driver name = 'Emer' relationship = 'wife' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.save_button() self.assertTrue( driver.find_element_by_xpath( '//*[@id="frmEmpEmgContact"]/fieldset/ol/li[3]/span').text == 'At least one phone number is required') def test_21_add_multiply_emg_contacts(self): name = 'Emer' relationship = 'wife' home_phone = '123456789' mobile_phone = '987654321' work_phone = '123366654' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.set_mobile_phone(mobile_phone) self.emergency_contacts_page.set_work_phone(work_phone) self.emergency_contacts_page.save_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.set_mobile_phone(mobile_phone) self.emergency_contacts_page.set_work_phone(work_phone) self.emergency_contacts_page.save_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) # deleting all emergency contacts self.driver.find_element_by_id('checkAll').click() self.driver.find_element_by_id("delContactsBtn").click() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Deleted')) def test_22_delete_emg_contacts(self): name = 'Emer' relationship = 'wife' home_phone = '123456789' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_contact_button() self.emergency_contacts_page.set_name(name) self.emergency_contacts_page.set_relationship(relationship) self.emergency_contacts_page.set_home_phone(home_phone) self.emergency_contacts_page.save_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) self.driver.find_element_by_css_selector("td>input").click() self.driver.find_element_by_id("delContactsBtn").click() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Deleted')) def test_23_add_attachment_emg_contacts(self): file_path = Pdf_file_path self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_attachment_button() self.emergency_contacts_page.choose_file(file_path) self.emergency_contacts_page.upload_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) # cleanup_deleting attachment self.driver.find_element_by_css_selector( "#tblAttachments > tbody > tr.odd > td.center > input").click() self.driver.find_element_by_id("btnDeleteAttachment").click() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Deleted')) def test_24_delete_attachment_emg_contacts(self): file_path = Pdf_file_path self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_attachment_button() self.emergency_contacts_page.choose_file(file_path) self.emergency_contacts_page.upload_button() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Saved')) self.driver.find_element_by_css_selector( "#tblAttachments > tbody > tr.odd > td.center > input").click() self.driver.find_element_by_id("btnDeleteAttachment").click() self.wait.until( expected_conditions.text_to_be_present_in_element( (By.CSS_SELECTOR, ".message.success"), 'Successfully Deleted')) def test_25_add_attachment_large_size(self): file_path = JPG_2_Mb_path self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.emergency_contacts_page.goto_page() self.emergency_contacts_page.add_attachment_button() self.emergency_contacts_page.choose_file(file_path) self.emergency_contacts_page.upload_button() self.assertEqual( '413 Request Entity Too Large', self.driver.find_element_by_xpath('/html/body/center[1]/h1').text)
from selenium.common.exceptions import TimeoutException, NoSuchElementException from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from pages.base_page import BasePage from pages.dashboard_page import DashboardPage from pages.login_page import LoginPage from pages.header_page import Header # driver = webdriver.Chrome() driver.get("https://opensource-demo.orangehrmlive.com/") login_page = LoginPage(driver) def get_num(driver, locator): for i in range(10): print(i) if i == 5: return True return False login_page.wait_until(get_num('sds')) driver.close()
def objectSetup(self, oneTimeSetUp): self.lp = LoginPage(self.driver)
def setUp(self): self.driver = webdriver.Chrome(executable_path=CHROME_EXECUTABLE_PATH) self.driver.get(DOMAIN) self.login_page = LoginPage(self.driver) self.personal_details_page = PersonalDetailsPage(self.driver)
def test_guest_on_login_page(browser): link = 'http://selenium1py.pythonanywhere.com/en-gb/accounts/login/' page = LoginPage(browser, link) page.open() page.should_be_login_page()
def logic_noLogin_state_buy(self): from pages.login_page import LoginPage self.el_buy_btn.click() return LoginPage(self.driver)
def setUpClass(cls): cls.driver = webdriver.Firefox() cls.zentao = AddBugPage(cls.driver) a = LoginPage(cls.driver) #实例化对象 a.login() #调用方法
def test_login(self): driver = self.driver driver.get(URL) login = LoginPage(driver) login.test_login(USERNAME, PASSWORD)
def test_login_url(browser): page = LoginPage(browser, LoginPageLocators.url_login) page.open() page.should_be_login_page()
class SessionHelper: def __init__(self, app, domain, credentials): self.driver = app.driver self.login_page = LoginPage(driver=self.driver, domain=domain) self.navigation_bar = NavigationBar(driver=self.driver) self.credentials = credentials def ensure_login(self, user): if not self.logged_in(): if user == "admin": self.login_as_admin() elif user == "guide": self.login_as_guide() elif user == "call_center": self.login_as_call_center() else: raise ValueError def login_as_admin(self): self.login_page.open() if self.is_login_page(): self.login(self.credentials['admin']['login'], self.credentials['admin']['password']) elif self.which_profile() == "admin": pass elif self.which_profile() == "guide": self.logout() else: print("Unable to log in...") print(self.which_profile()) def login_as_guide(self): self.login_page.open() if self.is_login_page(): self.login(self.credentials['guide']['login'], self.credentials['guide']['password']) elif self.which_profile() == "guide": pass elif self.which_profile() == "admin": self.logout() else: print("Unable to log in...") print(self.which_profile()) def login_as_call_center(self): self.login_page.open() sleep(1) if self.is_login_page(): self.login(self.credentials['call_center']['login'], self.credentials['call_center']['password']) self.login_page.choose_company(self.credentials['call_center']['company']) self.wait_for_company_opened() elif "ccu_companyList.aspx" in self.login_page.get_url(): self.login_page.choose_company(self.credentials['call_center']['company']) self.wait_for_company_opened() def login(self, login, password): self.login_page.login_input.send_keys(login) self.login_page.password_input.send_keys(password) self.login_page.login_button.click() def which_profile(self): try: current_profile = self.navigation_bar.profile_pic.get_attribute("src") if "admin_profile" in current_profile: return "admin" # elif "guide_profile" in current_profile: # return "guide" # elif "defaults" in current_profile: # return "call_center" # else: # print(current_profile) except NoSuchElementException: return "There is no profile pic on the page." def wait_for_company_opened(self): wait(lambda: self.which_profile() == "admin", timeout_seconds=60) # wait(lambda: self.which_profile() == "call_center", timeout_seconds=60) def is_login_page(self): return "login.aspx" in self.login_page.get_url() def ensure_logout(self): sleep(2) if self.logged_in(): self.logout() def logged_in(self): if len(self.navigation_bar.profile_pics) == 1: return True else: return False def logout(self): self.navigation_bar.menu_drop_down.click() self.navigation_bar.logout.click() def sell_certificate(self): self.navigation_bar.main_tab.click() self.navigation_bar.gift_certificates.click()
def __init__(self, app, domain, credentials): self.driver = app.driver self.login_page = LoginPage(driver=self.driver, domain=domain) self.navigation_bar = NavigationBar(driver=self.driver) self.credentials = credentials
def setUpClass(cls): cls.driver = webdriver.Firefox() cls.loginp = LoginPage(cls.driver)
def test_user_can_login(self, browser): # Arrange page = LoginPage(browser, URLLocators.LOGIN_URL) page.open() page.register_new_user() page.logout_user() page.check_is_user_logged_out() # Act page.go_to_login_page() page.login_user() # Assert page.check_is_user_logged_in()
def test_guest_can_go_to_login_page(browser): page = MainPage(browser, LINK) page.open() page.go_to_login_page() login_page = LoginPage(browser, browser.current_url) login_page.should_be_login_page()
def test_can_redirect_to_register_page(browser): LoginPage(browser).redirect_to_register_page()
def test_login(self): wd = WebDriverFactory(browser="chrome.driver") driver = wd.getWebDriverInstance() lt = LoginPage(driver) # Click and verify account lt.account() element = driver.find_element_by_xpath( "//button[@id='header-account-menu']") if element.is_enabled(): print("Test case TC001: Pass") else: print("Test Case TC001: Fail") # Click and verify Sign in lt.signIn() element = driver.find_element_by_xpath("//a[@id='account-signin']") if element.is_enabled(): print("Test Case Tc002: Pass") else: print("Test Case TC002: Fail") # Send email and verify email lt.email("*****@*****.**") email = driver.find_element_by_xpath("//input[@id='gss-signin-email']") if email.is_enabled(): print("Test Case Tc003: Pass") else: print("Test Case TC003: Fail") # # Click and verify 'Forgot Password Button' # lt.forgotPassword() # heading = driver.find_element_by_xpath("//h2[@id='gss-forgot-password-heading']") # print(heading.text) # if heading.text=="Reset your password": # print("Test Case TC004: Pass") # else: # print("Test Case TC004: Fail ") # Send Password and Verify lt.password("Ej12345679*") password = driver.find_element_by_xpath( "//input[@id='gss-signin-password']") if password.is_enabled(): print("Test Case TC004: Pass") else: print("Test Case TC004: Fail") # Click and verify Sign In Button lt.signInBtn() header_account = driver.find_element_by_xpath( "//button[@id='header-account-menu-signed-in']") if header_account.is_enabled(): print("Test Case TC005: Pass") else: print("Test Case TC005: Fail")
def test_arena(browser): # LOGUJĘ SIĘ DO demo.testarena.pl login_page = LoginPage(browser) login_page.login('*****@*****.**', 'sumXQQ72$L') # OTWIERAM ADMIN PANEL admin_button = browser.find_element_by_css_selector('.header_admin a') admin_button.click() # DODAJĘ NOWY PROJEKT button_links = browser.find_element_by_partial_link_text('DODAJ PROJEKT') button_links.click() name = browser.find_element_by_id('name') prefix = browser.find_element_by_id('prefix') save = browser.find_element_by_id('save') # UMIESZCZAM LOSOWO WYGENEROWANĄ NAZWĘ PROJEKTU W ZMIENNEJ - ZA POMOCĄ TEJ ZMIENNEJ BĘDĘ SZUKAĆ PROJEKTU W BAZIE name_of_project = get_random_string(10) name.send_keys(name_of_project) prefix.send_keys(get_random_string(6)) save.click() # WCHODZĘ DO SEKCJI PROJECTS (LEWE MENU) enter_the_section_projects = browser.find_element(By.CSS_SELECTOR, 'a.activeMenu') enter_the_section_projects.click() # SZUKAM NOWO-UTWORZONEGO PROJEKTU PO NAZWIE search_for_new_project = browser.find_element(By.CSS_SELECTOR, 'input#search') search_for_new_project.send_keys(name_of_project) # PASEK WYSZUKIWANIA button_for_search_new_project = browser.find_element( By.CSS_SELECTOR, 'a#j_searchButton.icon_search.icon-20') button_for_search_new_project.click() # PRZYCISK WYSZUKIWANIA (LUPA) # CZEKAM NA STRONĘ # wait = WebDriverWait(browser, 10) # grey_status_bar = (By.CSS_SELECTOR,'input#search') # wait.until(expected_conditions.visibility_of_element_located(grey_status_bar)) time_for_waiting = Waiting(browser) time_for_waiting.wait_for_loading() # TWORZĘ LISTĘ PROJEKTÓW W BAZIE projects = browser.find_elements(By.CSS_SELECTOR, 'tr td a') # NASTĘPNIE, TWORZĘ KOLEJNĄ LISTĘ, KTÓRA BĘDZIE ZAWIERAĆ NAZWY TYCH PROJEKTÓW list_with_names = [] for every_project in projects: list_with_names.append(every_project.text) # W ASERCJI SPRAWDZAM, CZY ZNAJDUJĄCA SIĘ W ZMIENNEJ NAZWA MOJEGO PROJEKTU - ZNAJDUJE SIĘ NA LIŚCIE NAZW STWORZONYCH PROJEKTÓW assert name_of_project in list_with_names print(name_of_project)
class PersonalDetailsTestCase(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome(executable_path=CHROME_EXECUTABLE_PATH) self.driver.get(DOMAIN) self.login_page = LoginPage(self.driver) self.personal_details_page = PersonalDetailsPage(self.driver) def tearDown(self): self.driver.quit() def test_01_see_personal_details(self): driver = self.driver self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.assertEqual( "Personal Details", driver.find_element_by_xpath( "//*[@id='pdMainContainer']/div[1]/h1").text) def test_02_edit_personal_details(self): driver = self.driver input_middle_name = 'Richard' employee_id = '101010' other_id = '033303' nick_name = 'Rick' military_status = 'N/A' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.personal_details_page.edit_button() self.personal_details_page.setup_middle_name(input_middle_name) self.personal_details_page.setup_emloyee_id(employee_id) self.personal_details_page.setup_other_id(other_id) self.personal_details_page.setup_emp_mick_name(nick_name) self.personal_details_page.setup_military_status(military_status) self.personal_details_page.save_button() self.personal_details_page.get_success_message() employee_full = driver.find_element_by_xpath( '//*[@id="profile-pic"]/h1').text self.assertTrue(input_middle_name in employee_full) def test_03_edit_restricted_personal_details(self): driver = self.driver input_ssn = '50001000' driver_license_num = '002002002' sin_number = '9998765' date_of_birth = '03-09-1985' marital_text = 'Married' self.login_page.login() self.login_page.get_welcome_massage() self.personal_details_page.goto_page() self.personal_details_page.edit_button() self.personal_details_page.set_driver_license_num(driver_license_num) self.personal_details_page.set_sin_number(sin_number) self.personal_details_page.set_ssn_number(input_ssn) self.personal_details_page.set_smoker_radio_button() self.personal_details_page.set_date_of_birth(date_of_birth) self.personal_details_page.select_marital_status(marital_text) self.personal_details_page.save_button() self.personal_details_page.get_success_message() value_snn = driver.find_element_by_id( 'personal_txtNICNo').get_attribute('value') self.assertEqual(input_ssn, value_snn)
def step_impl(context): login_page = LoginPage(context) login_page.alert_handler()
def test_login_page_has_all_elements(browser): LoginPage(browser).check_elements_exist()
def setUpClass(cls): cls.driver = driver_config() cls.driver.implicitly_wait(5) LoginPage(cls.driver).login() log().info('开始执行:客户页面的自动化测试') PosterPage(cls.driver).switch_to_current()
def get(self): l = LoginPage(self.driver) l.get().click_register() return self
def login(request): self = request.node.parent.obj lpg = LoginPage(self.driver) lpg.login(page=self.login_url_http)
def go_to_login_page(self): link = self._browser.find_element(*ProductPageLocators.LOGIN_PAGE_URL) link.click() return LoginPage(self._browser, self._browser.current_url)
def test_user_can_see_success_register(self, browser): page = LoginPage(browser, login_link) page.should_be_login_page()
def step_impl(context): login_page = LoginPage(context) login_page.click_on_second_alert()
def test_user_can_see_register_information(self, browser): page = LoginPage(browser, login_link) page.should_be_register_information(browser)
def test_login_to_account(driver, wait): '''TC-04 Verify if the registered user can log on the System''' web_page = MainPage(driver, wait) link_page = LoginPage(driver, wait) web_page.open() link_page.open() link_page.enter_email(email) link_page.enter_password(password) link_page.click_eye() link_page.submit_login() link_page.login_confirm()
def setUpClass(cls): cls.driver = webdriver.Chrome() cls.loginpage = LoginPage(cls.driver)
class Application: def __init__(self, driver, base_url): self.driver = driver driver.get(base_url) driver.maximize_window() self.wait = WebDriverWait(driver, 15) self.login_page = LoginPage(driver, base_url) self.persons_page = PersonsPage(driver, base_url) self.internal_page = InternalPage(driver, base_url) self.person_main_page = AddPersonMainPage(driver, base_url) self.enrollments_page = EnrollmentsPage(driver, base_url) self.dictionaries_page = DictionariesPage(driver, base_url) self.person_current_view_page = PersonCurrentViewPage(driver, base_url) self.person_main_view_page = PersonMainViewPage(driver, base_url) self.person_papers_view_page = PersonPapersViewPage(driver, base_url) self.person_enrollment_view_page = PersonEnrollmentViewPage(driver, base_url) self.enrollments_main_page = EnrollmentsMainPage(driver, base_url) self.enrollments_base_page = EnrollmentsBasePage(driver, base_url) self.main_page = AddPersonMainPage(driver, base_url) self.extra_page = AddPersonExtraPage(driver, base_url) self.address_page = AddPersonAddressesPage(driver, base_url) self.contact_page = AddPersonContactsPage(driver, base_url) self.papers_page = AddPersonPapersPage(driver, base_url) self.person_base_page = AddPersonPage(driver, base_url) self.person_enrollment = PersonEnrollmentPage(driver, base_url) def login(self, user, checkbox=False): """ Method performs login to the application. Use app.login(User.Admin) in tests :param user: User.Admin or User.random at the moment :param checkbox: True with checkbox remember me and False without it. Default value is False """ lp = self.login_page lp.is_this_page() lp.username_field.clear() lp.username_field.send_keys(user.username) lp.password_field.clear() lp.password_field.send_keys(user.password) if checkbox: lp.login_checkbox.click() lp.submit_button.click() self.internal_page.wait_until_page_generate() else: lp.submit_button.click() self.internal_page.wait_until_page_generate() def ensure_logged_in(self): """ Method ensures you are logged in, if not it enters as Admin """ element = self.wait.until(presence_of_element_located((By.CSS_SELECTOR, "nav, input[id='inputLogin']"))) if element.tag_name == "input": self.login(User.Admin()) def logout(self): """ Method performs logout from application """ ip = self.internal_page ip.is_this_page() ip.user_dropdown.click() ip.logout_button.click() def ensure_logout(self): """ Method ensures you are logged out from application, if not it performs logout """ element = self.wait.until(presence_of_element_located((By.CSS_SELECTOR, "nav, input[id='inputLogin']"))) if element.tag_name == "nav": self.logout() def is_logged_in(self): """ Method checks you are logged in :return True or False """ return self.internal_page.is_this_page() def is_not_logged_in(self): """ Method checks you are not logged in :return: True or False """ return self.login_page.is_this_page()
def log_in(browser, user=USERS['default_user']): login_page = LoginPage(browser) login_page.log_in(user)