def test_3_User_Cannot_Delete_User(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) profile_page = profilepage.init(self.driver) # Login to user login_page.login('*****@*****.**', 'Test@123') dashboard_page.navigatetouserpage() time.sleep(3) url = self.driver.current_url ###################### # # # Checkpoint # # # ###################### exitflag = 0 if url == 'https://app.realcrm.vn/403': print "Checkpoint1[Pass]: User cannot navigate to user manage page" assert True else: print "Checkpoint1[Failed]: User can navigate to user manage page" exitflag = 1 self.driver.quit() if exitflag == 1: assert False
def test_5_SendNotiWhenMessAllUser_AsUser(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) # Checkmessage button login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) ###################### # # # Checkpoint # # # ###################### exitflag = 0 try: verify = self.driver.find_elements(By.XPATH, ".//div[@id='btn-new-message']") except NoSuchElementException: pass if len(verify) == 0: print "Checkpoint1[Pass]: New message button not displayed" assert True else: print "Checkpoint1[Failed]: New message button displayed" exitflag = 1 ###################### # # ###### Clean up ###### # # ###################### # Delete seleadmin2, seleuser2, seleuser3 self.driver.get(realmax_url + "/logout") login_page.login(gb_admin, gb_admin_pass) WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) dashboard_page.navigatetouserpage() WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) time.sleep(2) user_page.deleteUser('*****@*****.**') time.sleep(2) user_page.deleteUser('*****@*****.**') time.sleep(2) user_page.deleteUser('*****@*****.**') time.sleep(5) # Delete seleadmin2 seleuser2 contact # dashboard_page.navigateToManageContactPage() # WebDriverWait(self.driver,10).until(cond.title_is("Manage contact")) # time.sleep(3) # contact_page.removeContact('*****@*****.**') # time.sleep(3) # contact_page.removeContact('*****@*****.**') if exitflag == 1: assert False self.driver.close()
def test_1_Change_Info_In_My_Profile(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) profile_page = profilepage.init(self.driver) # Create new user 'seleuser2' login_page.login(gb_admin, gb_admin_pass) dashboard_page.navigatetouserpage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage user")) time.sleep(2) user_btn = self.driver.find_element( *RealmaxUserPageLocators.addnew_user_btn) user_btn.click() user_page.addNewUser('sele', 'user2', 'Realmax', 'User', '*****@*****.**', 'Test@123', 'Test@123', '0904536477') self.driver.get(realmax_url + "/logout") # Login to user login_page.login('*****@*****.**', 'Test@123') dashboard_page.navigateToMyProfilePage() profile_page.edituserinfo('test', 'Change_Info_In_My_Profile', 'Test@123', 'Test@1234') WebDriverWait(self.driver, 10).until(cond.title_is("User")) time.sleep(2) dashboard_page.navigateToManageContactPage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage contact")) ###################### # # # Checkpoint # # # ###################### exitflag = 0 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@1234') try: text_change_info = self.driver.find_elements( By.XPATH, ".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown']/a[@class='dropdown-toggle']//span[contains(.,'test Change_Info_In_My_Profile')]" ) except NoSuchElementException: pass if len(text_change_info) > 0: print "Checkpoint1[Pass]: Login success 'test Change_Info_In_My_Profile' displayed" assert True else: print "Checkpoint1[Failed]: Login not success 'test Change_Info_In_My_Profile' not displayed" exitflag = 1 self.driver.quit() if exitflag == 1: assert False
def test(self): login_page = loginpage.init(self.driver) login_page.login('root', 'abc123') # Create a test company dashboard_page = dashboardpage.init(self.driver) dashboard_page.navigatetocompanypage() WebDriverWait(self.driver,10).until(cond.title_is("Manage company")) company_page = companypage.init(self.driver) company_page.addnewcompany('selecompany', 'Selecompany') self.driver.get("https://www.realmax.ga") # Create admin user dashboard_page = dashboardpage.init(self.driver) dashboard_page.navigatetouserpage() time.sleep(2) user_btn = self.driver.find_element(*RealmaxUserPageLocators.addnew_user_btn) user_btn.click() user_page = userpage.init(self.driver) user_page.addNewUser('seleadmin','sele','Selecompany','Administrator','*****@*****.**','Test@123','Test@123','0904536477') WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) # Add valid token with admin self.driver.get("https://www.realmax.ga/logout") login_page = loginpage.init(self.driver) login_page.login('*****@*****.**', 'Test@123') userprofile_link = self.driver.find_element(*RealmaxMainPageLocators.userprofile_link) userprofile_link.click() mycompany_link = self.driver.find_element(*RealmaxMainPageLocators.mycompany_link) mycompany_link.click() ###################### # # # Checkpoint # # # ###################### access_token_tb = self.driver.find_element(*RealmaxCompanyPageLocators.accesstoken_tb) access_token_tb.send_keys(gb_access_token) refesh_token_tb = self.driver.find_element(*RealmaxCompanyPageLocators.refresh_tb) refesh_token_tb.send_keys(gb_refesh_token) checktoken_btn = self.driver.find_element(*RealmaxCompanyPageLocators.checktoken_btn) checktoken_btn.click() time.sleep(5) token_success_message = self.driver.find_element(*RealmaxCompanyPageLocators.token_success_message) # Check Verify message appear when click in verify in sele company assert token_success_message.is_displayed() ok_btn = self.driver.find_element(*RealmaxCompanyPageLocators.ok_btn) ok_btn.click() ###################### # # # Clean up # # # ###################### self.driver.get("https://www.realmax.ga/logout") login_page.login('root', 'abc123') dashboard_page.navigatetouserpage() user_page.deleteUser('*****@*****.**') self.driver.get("https://www.realmax.ga") dashboard_page.navigatetocompanypage() company_page.deletecompany('selecompany')
def test_4_Grant_Tag_Permission_To_User(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) profile_page = profilepage.init(self.driver) tag_page = tagpage.init(self.driver) wait = WebDriverWait(self.driver, 10) login_page.login(gb_admin, gb_admin_pass) dashboard_page.navigatetouserpage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage user")) time.sleep(2) user_page.appplyTagToUser('*****@*****.**', 'Realmax') self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') dashboard_page.navigateToTagPage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage tag")) ###################### # # # Checkpoint # # # ###################### exitflag = 0 try: wait.until( ec.visibility_of_element_located(( By.XPATH, ".//table[@id='table_data']//tr[contains(.,'Realmax')]//td[contains(.,'Realmax')]" ))) realmax_tag = self.driver.find_elements( By.XPATH, ".//table[@id='table_data']//tr[contains(.,'Realmax')]//td[contains(.,'Realmax')]" ) except NoSuchElementException: pass if len(realmax_tag) > 0: print "Checkpoint1[Pass]: Realmax tag displayed" assert True else: print "Checkpoint1[Failed]: Realmax tag not displayed" exitflag = 1 self.driver.quit() if exitflag == 1: assert False
def test_Apply_Tag_To_Contact_And_User(self): # Login to realmax login_page = loginpage.init(self.driver) login_page.login(gb_admin, gb_admin_pass) WebDriverWait(self.driver, 10).until(cond.title_is("Dashboard")) dashboard_page = dashboardpage.init(self.driver) dashboard_page.navigatetouserpage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage user")) time.sleep(2) user_page = userpage.init(self.driver) user_page.appplyTagToUser('*****@*****.**', 'Realmax') # Add new contact apply tag time.sleep(2) dashboard_page.navigateToManageContactPage() time.sleep(2) contact_page = contactpage.init(self.driver) contact_page.searchContact('email', '*****@*****.**') contact_page.applyTagToContact('*****@*****.**', 'Realmax') ###################### # # # Checkpoint # # # ###################### exitflag = 0 self.driver.get(realmax_url + "/logout") login_page.login(gb_user, gb_user_pass) dashboard_page.navigateToTagPage() time.sleep(3) try: realmax_tag = self.driver.find_elements( By.XPATH, ".//table[@id='table_data']//tr[contains(.,'Realmax')]") except NoSuchElementException: pass if len(realmax_tag) > 0: print "Checkpoint1[Pass]: Realmax tag displayed" assert True else: print "Checkpoint1[Failed]: Realmax tag not displayed" exitflag = 1 action = actions.init(self.driver) action.click('tag', 'apply_contact', 'Realmax') time.sleep(5) try: sele_contact = self.driver.find_elements( By.XPATH, ".//div[@id='list-selected-tags']//label[contains(.,'Seleuser User')]" ) except NoSuchElementException: pass if len(sele_contact) > 0: print "Checkpoint2[Pass]: Seleuser contact displayed" assert True else: print "Checkpoint2[Failed]: Seleuser contact not displayed" exitflag = 1 time.sleep(5) save_btn = self.driver.find_element(*RealmaxTagPageLocators.save_btn) save_btn.click() time.sleep(2) ok_btn = self.driver.find_element(*RealmaxTagPageLocators.ok_btn) ok_btn.click() ###################### # # ###### Clean up ###### # # ###################### tag_page = tagpage.init(self.driver) tag_page.removeContagInTag('Realmax', 'Seleuser User') self.driver.get(realmax_url + "/logout") login_page.login(gb_admin, gb_admin_pass) dashboard_page.navigatetouserpage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage user")) time.sleep(2) user_page = userpage.init(self.driver) user_page.removeAllTagsInUser('*****@*****.**') if exitflag == 1: assert False
def test_1_SendNoti_When_Delete_User(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) checkElement = element.init(self.driver) # Login to realmax login_page.login(gb_admin, gb_admin_pass) # Add adminsele2 dashboard_page.navigatetouserpage() WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) time.sleep(2) user_btn = self.driver.find_element(*RealmaxUserPageLocators.addnew_user_btn) user_btn.click() user_page.addNewUser('sele','admin2','Realmax','Administrator','*****@*****.**','Test@123','Test@123','0904536477') # Add usersele2 WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) time.sleep(2) user_btn = self.driver.find_element(*RealmaxUserPageLocators.addnew_user_btn) user_btn.click() user_page.addNewUser('sele','user2','Realmax','User','*****@*****.**','Test@123','Test@123','0904536477') self.driver.get(realmax_url + "/logout") # Delete usersele2 login_page.login(gb_admin, gb_admin_pass) WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) dashboard_page.navigatetouserpage() user_page.deleteUser('*****@*****.**') ###################### # # # Checkpoint # # # ###################### exitflag = 0 #Check noti in seleadmin2 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) noti_link = self.driver.find_element(*RealmaxMainPageLocators.noti_link) noti_link.click() time.sleep(5) try: sele_delete_noti = self.driver.find_elements(By.XPATH,".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown dropdown-notif open']/ul[@class='dropdown-menu notifications']//li[@class='notif-items']//li[contains(.,'*****@*****.**') and contains(.,'was deleted by [email protected]') and contains(.,'less than a minute ago')]") except NoSuchElementException: pass if len(sele_delete_noti) > 0: print "Checkpoint1[Pass]: Delete seleuser notification displayed" assert True else: print "Checkpoint1[Failed]: Delete seleuser notification not displayed" exitflag = 1 ###################### # # ###### Clean up ###### # # ###################### # Delete seleadmin2 seleuser2 contact # self.driver.get(realmax_url + "/logout") # login_page.login(gb_admin, gb_admin_pass) # WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) # dashboard_page.navigateToManageContactPage() # contact_page.removeContact('*****@*****.**') # time.sleep(3) # contact_page.removeContact('*****@*****.**') if exitflag == 1: assert False self.driver.close()
def test_4_SendNotiWhenMessAllUser_AsAdmin(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) # Send message to all users login_page.login(gb_admin, gb_admin_pass) WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) dashboard_page.navigatetouserpage() now = datetime.datetime.now() mess = now.strftime("%H:%M:%S") user_page.sendMessageToUsers( mess, 'https://www.google.com') ###################### # # # Checkpoint # # # ###################### exitflag = 0 # Check mess admin2 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) noti_link = self.driver.find_element(*RealmaxMainPageLocators.noti_link) noti_link.click() time.sleep(5) try: verify = self.driver.find_elements(By.XPATH, ".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown dropdown-notif open']/ul[@class='dropdown-menu notifications']//li[@class='notif-items']//li[contains(.,'" + mess + "')]") except NoSuchElementException: pass if len(verify) > 0: print "Checkpoint1[Pass]: Message" + mess + "displayed in seleadmin account" assert True else: print "Checkpoint1[Failed]: Message" + mess + "not displayed in seleadmin account" exitflag = 1 # Check mess user2 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) noti_link = self.driver.find_element(*RealmaxMainPageLocators.noti_link) noti_link.click() time.sleep(5) try: verify = self.driver.find_elements(By.XPATH, ".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown dropdown-notif open']/ul[@class='dropdown-menu notifications']//li[@class='notif-items']//li[contains(.,'" + mess + "')]") except NoSuchElementException: pass if len(verify) > 0: print "Checkpoint2[Pass]: Message" + mess + "displayed in seleuser account" assert True else: print "Checkpoint2[Failed]: Message" + mess + "not displayed in seleuser account" exitflag = 1 if exitflag == 1: assert False self.driver.close()
def test_3_SendNoti_When_Mess_To_Specific_User(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) # Login to realmax login_page.login(gb_admin, gb_admin_pass) WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) dashboard_page.navigatetouserpage() # Add user sele2 WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) time.sleep(2) user_btn = self.driver.find_element(*RealmaxUserPageLocators.addnew_user_btn) user_btn.click() user_page.addNewUser('sele','user2','Realmax','User','*****@*****.**','Test@123','Test@123','0904536477') # Add user sele3 WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) time.sleep(2) user_btn = self.driver.find_element(*RealmaxUserPageLocators.addnew_user_btn) user_btn.click() user_page.addNewUser('sele','user3','Realmax','User','*****@*****.**','Test@123','Test@123','0904536477') # Send message to specific users WebDriverWait(self.driver,10).until(cond.title_is("Manage user")) dashboard_page.navigatetouserpage() names = ['sele admin2', 'sele user2'] now = datetime.datetime.now() mess = now.strftime("%H:%M:%S") time.sleep(2) user_page.sendMessageToUsers( mess, 'https://www.google.com', names) ###################### # # # Checkpoint # # # ###################### exitflag = 0 # Check mess admin2 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) noti_link = self.driver.find_element(*RealmaxMainPageLocators.noti_link) noti_link.click() time.sleep(5) try: verify = self.driver.find_elements(By.XPATH, ".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown dropdown-notif open']/ul[@class='dropdown-menu notifications']//li[@class='notif-items']//li[contains(.,'" + mess + "')]") except NoSuchElementException: pass if len(verify) > 0: print "Checkpoint1[Pass]: Message" + mess + "displayed in seleadmin account" assert True else: print "Checkpoint1[Failed]: Message" + mess + "not displayed in seleadmin account" exitflag = 1 # Check mess user2 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) noti_link = self.driver.find_element(*RealmaxMainPageLocators.noti_link) noti_link.click() time.sleep(5) try: verify = self.driver.find_elements(By.XPATH, ".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown dropdown-notif open']/ul[@class='dropdown-menu notifications']//li[@class='notif-items']//li[contains(.,'" + mess + "')]") except NoSuchElementException: pass if len(verify) > 0: print "Checkpoint2[Pass]: Message" + mess + "displayed in seleuser account" assert True else: print "Checkpoint2[Failed]: Message" + mess + "not displayed in seleuser account" exitflag = 1 # Check mess user3 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') WebDriverWait(self.driver,10).until(cond.title_is("Dashboard")) noti_link = self.driver.find_element(*RealmaxMainPageLocators.noti_link) noti_link.click() time.sleep(5) try: verify = self.driver.find_elements(By.XPATH, ".//ul[@class='nav navbar-nav navbar']/li[@class='dropdown dropdown-notif open']/ul[@class='dropdown-menu notifications']//li[@class='notif-items']//li[contains(.,'" + mess + "')]") except NoSuchElementException: assert True if len(verify) == 0: print "Checkpoint3[Pass]: Message" + mess + " not displayed in seleuser account" assert True else: print "Checkpoint3[Failed]: Message" + mess + "displayed in seleuser account" exitflag = 1 if exitflag == 1: assert False self.driver.close()
def test_2_Admin_Edit_Exist_User(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) profile_page = profilepage.init(self.driver) # Login to user login_page.login(gb_admin, gb_admin_pass) dashboard_page.navigatetouserpage() user_page.editUser('*****@*****.**', 'sele', 'user2', 'Test@123') ###################### # # # Checkpoint # # # ###################### exitflag = 0 exitflag_cp1 = 0 WebDriverWait(self.driver, 10).until(cond.title_is("Manage user")) try: pages = self.driver.find_elements( By.XPATH, ".//ul[@class='pagination']//li[@class='paginate_button page-item ']" ) except NoSuchElementException: pass if len(pages) > 0: i = 2 while i <= len(pages) + 2: try: sele2_user = self.driver.find_elements_by_xpath( ".//table[@id='table_data']/tbody//tr[contains(.,'sele') and contains(., 'user2')]" ) except NoSuchElementException: pass if len(sele2_user) == 0: time.sleep(2) page_navigate_btn = self.driver.find_element( By.XPATH, ".//ul[@class='pagination']//a[contains(.,'" + str(i) + "')]") page_navigate_btn.click() time.sleep(3) i += 1 exitflag_cp1 = 1 else: exitflag_cp1 = 0 break if exitflag_cp1 == 0: print "Checkpoint1[Pass]: Sele user2 displayed" assert True else: print "Checkpoint1[Failed]: Sele user2 not displayed" exitflag = 1 self.driver.get(realmax_url + "/logout") login_page.login('*****@*****.**', 'Test@123') try: text_change_info = self.driver.find_elements( By.XPATH, ".//ul[@class='nav navbar-nav navbar-right']/li[@class='dropdown']/a[@class='dropdown-toggle']//span[contains(.,'sele user2')]" ) except NoSuchElementException: pass if len(text_change_info) > 0: print "Checkpoint2[Pass]: Login success 'sele user2' displayed" assert True else: print "Checkpoint2[Failed]: Login not success 'tsele user2' not displayed" exitflag = 1 self.driver.close() if exitflag == 1: assert False
def test_5_Delete_A_User(self): # INIT login_page = loginpage.init(self.driver) dashboard_page = dashboardpage.init(self.driver) user_page = userpage.init(self.driver) contact_page = contactpage.init(self.driver) profile_page = profilepage.init(self.driver) tag_page = tagpage.init(self.driver) wait = WebDriverWait(self.driver, 10) login_page.login(gb_admin, gb_admin_pass) dashboard_page.navigatetouserpage() WebDriverWait(self.driver, 10).until(cond.title_is("Manage user")) time.sleep(2) user_page.deleteUser('*****@*****.**') time.sleep(10) ###################### # # # Checkpoint # # # ###################### exitflag = 0 try: pages = self.driver.find_elements( By.XPATH, ".//ul[@class='pagination']//li[@class='paginate_button page-item ']" ) except NoSuchElementException: pass if len(pages) > 0: i = 2 while i <= len(pages) + 2: try: sele_user = self.driver.find_elements_by_xpath( ".//table[@id='table_data']//tr[contains(.,'*****@*****.**')]//td[contains(.,'*****@*****.**')]" ) except NoSuchElementException: pass if len(sele_user) > 0: exitflag = 1 break else: if i == len(pages) + 2: break else: time.sleep(2) page_navigate_btn = self.driver.find_element( By.XPATH, ".//ul[@class='pagination']//a[contains(.,'" + str(i) + "')]") page_navigate_btn.click() time.sleep(3) i += 1 if exitflag == 0: print "Checkpoint1[Pass]: User sele2 deleted successfully" assert True else: print "Checkpoint1[Failed]: User sele2 not deleted successfully" exitflag = 1 ###################### # # ###### Clean up ###### # # ###################### # dashboard_page.navigateToManageContactPage() # WebDriverWait(self.driver,10).until(cond.title_is("Manage contact")) # time.sleep(10) # contact_page.removeContact('*****@*****.**') self.driver.quit() if exitflag == 1: assert False