def login(self, request): """docstring for login""" form = LoginForm() page_url = request.path + "?" + request.query_string # if google user login guser = gusers.get_current_user() if guser: # google user login already, email = guser.email() user = auth.User.all().filter("email =", email).get() if not user: import random, string password = "".join(random.choice(string.ascii_uppercase + string.digits) for x in range(6)) user = auth.User( email=email, fullname=guser.nickname(), username=(guser.user_id() + "_google"), password=password ) # an always false password user.change_to_gravatar_icon() user.save() auth.login(user) back_url = request.get("back_url", "/") if back_url: return redirect(back_url) else: google_login_url = gusers.create_login_url(settings.LOGIN_URL) return template("page_site_login.html", locals())
def testSelectSiteForCRUDOUser(self): """ Verify the by logging using valid CRUDO privilege user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) try: WebDriverWait(self.driver, 50).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/search_image_view"))) search = self.driver.find_element_by_id( "com.view.viewglass:id/search_image_view") search.click() search_text = self.driver.find_element_by_id( "com.view.viewglass:id/search_site_edit_text") # search for the site and press ENTER search_text.send_keys(config.sites['Default']) # self.self.driver.press_keycode(66) size = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").size location = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").location x = size['width'] / 2 y = location['y'] + size['height'] * 2 self.driver.tap([(x, y)]) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/viewLogoLL")) > 0: y = location['y'] + size['height'] * 2.5 self.driver.tap([(x, y)]) except TimeoutException: raiseExceptions("Failed to reach Select Site screen")
def testRemoveDeleteZoneGroupForRO(self): auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) sleep(20) if commonFunctions.foundAlert(self.driver): commonFunctions.respondToAlert(self.driver, 0) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/view_btnTV")) > 0: commonFunctions.navIcon(self.driver) commonFunctions.navIcon(self.driver) if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/navigation_zonesTV"))): self.driver.find_element_by_id( "com.view.viewglass:id/navigation_zonesTV").click() else: raiseExceptions("Zones option in navigation menu is missing") if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_zonesTV"))): pass else: raiseExceptions("Zones heading is missing") foundZonegroupabc = False size = 0 location = 0 if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/listItemNameTV")) > 0: zonegroups = self.driver.find_elements( By.ID, "com.view.viewglass:id/listItemNameTV") for group in zonegroups: if group.text == "abc": foundZonegroupabc = True size = group.size location = group.location break if foundZonegroupabc: startx = location['x'] + size['width'] endx = location['x'] + size['width'] / 2 y = location['y'] + size['height'] / 2 self.driver.swipe(startx, y, endx, y, 3000) x = location['x'] + size['width'] - 10 self.driver.tap([(x, y)]) sleep(5) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/listItemNameTV")) > 0: zonegroups = self.driver.find_elements( By.ID, "com.view.viewglass:id/listItemNameTV") for group in zonegroups: if group.text == "abc": raiseExceptions("Zonegroup was not deleted")
def testNoSiteAssignedForUserInVRM(self): """ Verify the exceptional handling by logging using invalid user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) auth.logout(self.driver)
def testLoginUsingCRUDOUser(self): """ Verify the app authentication by logging using valid CRUDO privilege user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) auth.signout(self.driver)
def testLoginTo1dot2Site(self): """ Verify the app authentication by logging using valid RO privilege user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['1dot2System']['username'], config.users['1dot2System']['password']) site.selectSite(self.driver, 'B195 Ballroom')
def testUnconfiguredUserInVRM(self): """ Verify the exceptional handling by logging using invalid user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'UserNotConfiguredInVRM') auth.login(self.driver, config.users['UserNotConfiguredInVRM']['username'], config.users['UserNotConfiguredInVRM']['password'])
def testUIComponentsOfProfileScreenForRO(self): auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) sleep(20) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/home_controlIV")) > 0: pass elif len( self.driver.find_elements( By.XPATH, "//android.widget.Button[@resource-id='com.view.viewglass:id/button_cancel']" )) > 0: site.selectSite(self.driver, config.users['RO']['testsite']) if commonFunctions.foundAlert(self.driver): commonFunctions.respondToAlert(self.driver, 0) commonFunctions.navIcon(self.driver) if WebDriverWait(self.driver, 20).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/username_navigationTV"))): self.driver.find_element_by_id( "com.view.viewglass:id/username_navigationTV").click() else: raiseExceptions("Profile option in navigation menu is missing") if WebDriverWait(self.driver, 20).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_myProfileTV"))): pass else: raiseExceptions("Profile heading is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/startup_myProfileTV")) <= 0: raiseExceptions("Send Feedback tab is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/change_appserverIP_myProfileTV") ) <= 0: raiseExceptions("Change Appserver IP is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/tourPreferenceTV")) <= 0: raiseExceptions("Tour Preference is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/mobiledataTV")) <= 0: raiseExceptions("Cellular Data is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/signout_myProfileTV")) <= 0: raiseExceptions("Sign Out button is missing") self.driver.find_element_by_xpath( "//android.widget.TextView[@text='Sign Out']").click()
def testSingleSiteUserLogin(self): """ Verify the exceptional handling by logging using invalid user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'RUO') auth.login(self.driver, config.users['SingleSite']['username'], config.users['SingleSite']['password']) sleep(30) auth.logout(self.driver)
def testLogoutFunctionality(self): """ Verify the logout functionality """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) sleep(30) auth.signout(self.driver)
def testSelectSiteNoSiteAssignToUserInVRM(self): """ Verify the functionality of logging into a user not assigned to any site """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.checkIfUserIsLoggedIn(self.driver, 0, 'UserNotConfiguredInVRM') auth.login(self.driver, config.users['UserNotConfiguredInVRM']['username'], config.users['UserNotConfiguredInVRM']['password'])
def testSelectSiteCancelFunctionality(self): """ Verify the functionality of the cancel button """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) try: WebDriverWait(self.driver, 50).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/search_image_view"))) search = self.driver.find_element_by_id( "com.view.viewglass:id/search_image_view") search.click() search_text = self.driver.find_element_by_id( "com.view.viewglass:id/search_site_edit_text") # search for the site and press ENTER search_text.send_keys(config.sites['Default']) # self.self.driver.press_keycode(66) size = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").size location = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").location x = size['width'] / 2 y = location['y'] + size['height'] * 2 self.driver.tap([(x, y)]) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/viewLogoLL")) > 0: y = location['y'] + size['height'] * 2.5 self.driver.tap([(x, y)]) except TimeoutException: raiseExceptions("Failed to reach Select Site screen") try: WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//android.widget.TextView[@text='Cancel']"))) if len( self.driver.find_elements( By.XPATH, "//android.widget.TextView[@text='Cancel']")) == 0: raiseExceptions("Cancel button was not found in time.") else: self.driver.find_element_by_xpath( "//android.widget.TextView[@text='Cancel']").click() except TimeoutException: raiseExceptions("Cancel button did not stop the process") if common.foundAlert(self.driver): common.respondToAlert(self.driver, 1)
def login_post(self, request): """The post handler for user login""" form = LoginForm(data=request.POST) if form.is_valid(): auth.login(form.user) back_url = request.get("back_url", "/") if back_url: return redirect(back_url) else: return template("page_site_login_successful.html", locals()) else: return template("page_site_login.html", locals())
def testSelectSiteSignoutFunctionality(self): """ Verify the functionality of the Sign Out button """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) try: WebDriverWait(self.driver, 50).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/button_cancel"))) self.driver.find_element_by_id( "com.view.viewglass:id/button_cancel").click() except TimeoutException: raiseExceptions(" Missing Sign Out button")
def testSelectSiteForOneSiteAssignToUser(self): """ Verify the functionality of logging into a user assigned to only one site """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'RUO') auth.login(self.driver, config.users['SingleSite']['username'], config.users['SingleSite']['password']) if len( self.driver.find_elements( By.XPATH, "//android.widget.TextView[@text='Select Site']")) > 0: raiseExceptions("This user has more than one site") else: pass
def testLoginUsingROUser(self): """ Verify the app authentication by logging using valid RO privilege user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/home_controlIV")) > 0: auth.logout(self.driver) elif len( self.driver.find_elements( By.XPATH, "//android.widget.Button[@resource-id='com.view.viewglass:id/button_cancel']" )) > 0: auth.signout(self.driver)
def testEditZoneGroupForRO(self): auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) sleep(20) if commonFunctions.foundAlert(self.driver): commonFunctions.respondToAlert(self.driver, 0) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/view_btnTV")) > 0: commonFunctions.navIcon(self.driver) commonFunctions.navIcon(self.driver) if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/navigation_zonesTV"))): self.driver.find_element_by_id( "com.view.viewglass:id/navigation_zonesTV").click() else: raiseExceptions("Zones option in navigation menu is missing") if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_zonesTV"))): pass else: raiseExceptions("Zones heading is missing") if zones_and_scenes.findZonegroup(self.driver, "abc") == False: zones_and_scenes.quickCreateZonegroup(self.driver, "abc") zones_and_scenes.findZonegroup(self.driver, "abc") if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//android.widget.TextView[@text='abc']"))): commonFunctions.editbutton(self.driver) if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_createZoneGrpTV"))): zones = self.driver.find_elements( By.ID, "com.view.viewglass:id/zone_item_select_zoneTV") zones[2].click() zones[3].click() commonFunctions.savebutton(self.driver) else: raiseExceptions("Edit button led to the wrong screen")
def testSelectSiteForRUOUser(self): """ Verify the app authentication by logging using valid RUO privilege user """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'RUO') auth.login(self.driver, config.users['RUO']['username'], config.users['RUO']['password']) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/home_controlIV")) > 0: print("RUO user only has one site") elif len( self.driver.find_elements( By.XPATH, "//android.widget.Button[@resource-id='com.view.viewglass:id/button_cancel']" )) > 0: try: WebDriverWait(self.driver, 50).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/search_image_view"))) search = self.driver.find_element_by_id( "com.view.viewglass:id/search_image_view") search.click() search_text = self.driver.find_element_by_id( "com.view.viewglass:id/search_site_edit_text") # search for the site and press ENTER search_text.send_keys(config.sites['Default']) # self.self.driver.press_keycode(66) size = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").size location = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").location x = size['width'] / 2 y = location['y'] + size['height'] * 2 self.driver.tap([(x, y)]) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/viewLogoLL")) > 0: y = location['y'] + size['height'] * 2.5 self.driver.tap([(x, y)]) except TimeoutException: raiseExceptions("Failed to reach Select Site screen")
def testCreateZoneGroupForRO(self): auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) sleep(20) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/home_controlIV")) > 0: pass elif len( self.driver.find_elements( By.XPATH, "//android.widget.Button[@resource-id='com.view.viewglass:id/button_cancel']" )) > 0: site.selectSite(self.driver, config.users['RO']['testsite']) if commonFunctions.foundAlert(self.driver): commonFunctions.respondToAlert(self.driver, 0) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/view_btnTV")) > 0: commonFunctions.navIcon(self.driver) commonFunctions.navIcon(self.driver) if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/navigation_zonesTV"))): self.driver.find_element_by_id( "com.view.viewglass:id/navigation_zonesTV").click() else: raiseExceptions("Zones option in navigation menu is missing") if WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_zonesTV"))): pass else: raiseExceptions("Zones heading is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/actZone_addIV")) > 0: raiseExceptions("RO user is able to add a zonegroup")
def testSelectNotReachableSite(self): """ Verify the exceptional handling by logging into a site that is not reachable """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) if WebDriverWait(self.driver, 50).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/search_image_view"))): search = self.driver.find_element_by_id( "com.view.viewglass:id/search_image_view") search.click() search_text = self.driver.find_element_by_id( "com.view.viewglass:id/search_site_edit_text") # search for the site and press ENTER search_text.send_keys("1.2CONFsys") self.driver.press_keycode(66) size = self.driver.find_element_by_id( "com.view.viewglass:id/siteList_searchResultCountTV").size location = self.driver.find_element_by_id( "com.view.viewglass:id/siteList_searchResultCountTV").location x = size['width'] / 2 y = location['y'] + size['height'] * 3 self.driver.tap([(x, y)]) else: raiseExceptions("Failed to reach Select Site screen") sleep(10) if len( self.driver.find_elements( By.XPATH, "//android.widget.TextView[@text='Site is not reachable. Please try again later or contact Facilities Manager or View Support at [email protected] or (855)-478-8468']" )) > 0: common.respondToAlert(self.driver, 0) else: raiseExceptions( "Exception handling for unreachable site is missing")
def testSelectSiteSearchFunctionality(self): """ Verify the functionality of the search bar for selecting a site """ auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO') auth.login(self.driver, config.users['CRUDO']['username'], config.users['CRUDO']['password']) try: WebDriverWait(self.driver, 50).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/search_image_view"))) except TimeoutException: raiseExceptions("Search field is missing") search = self.driver.find_element_by_id( "com.view.viewglass:id/search_image_view") search.click() search_text = self.driver.find_element_by_id( "com.view.viewglass:id/search_site_edit_text") # search for the site and press ENTER search_text.send_keys(config.sites['Default']) # self.self.driver.press_keycode(66) size = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").size location = self.driver.find_element_by_id( "com.view.viewglass:id/viewLogoLL").location x = size['width'] / 2 y = location['y'] + size['height'] * 2 self.driver.tap([(x, y)]) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/viewLogoLL")) > 0: y = location['y'] + size['height'] * 2.5 self.driver.tap([(x, y)]) else: raiseExceptions("Search function did not return any results.")
def testAddNewSceneForRO(self): auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) sleep(20) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/home_controlIV")) > 0: pass elif len( self.driver.find_elements( By.XPATH, "//android.widget.Button[@resource-id='com.view.viewglass:id/button_cancel']" )) > 0: site.selectSite(self.driver, config.users['RO']['testsite']) if commonFunctions.foundAlert(self.driver): commonFunctions.respondToAlert(self.driver, 0) commonFunctions.navIcon(self.driver) if WebDriverWait(self.driver, 60).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/navigation_scenesTV"))): self.driver.find_element_by_id( "com.view.viewglass:id/navigation_scenesTV").click() else: raiseExceptions("Scenes option in navigation menu is missing") WebDriverWait(self.driver, 10).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/scene_headertext"))) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/scene_addIconIV")) > 0: raiseExceptions("Bug: RO user is able to add a new scene") auth.logout(self.driver)
def testAboutForRO(self): auth.checkIfUserIsLoggedIn(self.driver, 0, 'RO') auth.login(self.driver, config.users['RO']['username'], config.users['RO']['password']) sleep(20) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/home_controlIV")) > 0: pass elif len( self.driver.find_elements( By.XPATH, "//android.widget.Button[@resource-id='com.view.viewglass:id/button_cancel']" )) > 0: site.selectSite(self.driver, config.users['RO']['testsite']) if commonFunctions.foundAlert(self.driver): commonFunctions.respondToAlert(self.driver, 0) commonFunctions.navIcon(self.driver) if WebDriverWait(self.driver, 20).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/settingIcon_navigationIV"))): self.driver.find_element_by_id( "com.view.viewglass:id/settingIcon_navigationIV").click() else: raiseExceptions("Settings option in navigation menu is missing") if WebDriverWait(self.driver, 20).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_settingScreen_wallSwitchTV" ))): pass else: raiseExceptions("Settings heading is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/act_about_wallSwitchTV")) > 0: self.driver.find_element_by_id( "com.view.viewglass:id/act_about_wallSwitchTV").click() if WebDriverWait(self.driver, 20).until( EC.presence_of_element_located( (By.ID, "com.view.viewglass:id/title_settingTV"))): pass else: raiseExceptions("About Viewglass heading is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/application_settingTV")) <= 0: raiseExceptions("Application subheading is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/version_settingLL")) <= 0: raiseExceptions("Version is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/deviceid_settingLL")) <= 0: raiseExceptions("Show Device is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/masterController_settingsTV")) <= 0: raiseExceptions("Master Controller subheading is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/site_settingLL")) <= 0: raiseExceptions("Site is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/mode_settingLL")) <= 0: raiseExceptions("Mode is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/name_settingLL")) <= 0: raiseExceptions("Name is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/date_settingTV")) <= 0: raiseExceptions("Date setting is missing") size = self.driver.find_element_by_id( "com.view.viewglass:id/appInfoParentLL").size location = self.driver.find_element_by_id( "com.view.viewglass:id/appInfoParentLL").location self.driver.swipe(location['x'] + size['width'] / 2, location['y'] + size['height'] - 10, location['x'] + size['width'] / 2, location['y'] + 10, 2000) if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/time_settingLL")) <= 0: raiseExceptions("Time setting is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/setting_timeZoneLL")) <= 0: raiseExceptions("Timezone setting is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/setting_PltfrmVersionLL")) <= 0: raiseExceptions("Platform Version is missing") if len( self.driver.find_elements( By.ID, "com.view.viewglass:id/setting_DatabaseVersionLL")) <= 0: raiseExceptions("Database Version is missing")
def on_start(self): """Logins and stuff before starting a user session.""" login()