示例#1
0
def verifyInvalidTintsNotFound(driver, tint):
    if len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintImage_controlIV")) > 0:
        driver.find_element_by_id(
            "com.view.viewglass:id/tintImage_controlIV").click()
        if commonFunctions.foundAlert(driver):
            commonFunctions.respondToAlert(driver, 1)
    elif len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintLevelNum_controlTV")) > 0:
        pass
    else:
        selectRandomTint(driver)
        commonFunctions.overridebutton(driver)
        if len(
                driver.find_elements(
                    By.ID, "com.view.viewglass:id/tintImage_controlIV")) > 0:
            driver.find_element_by_id(
                "com.view.viewglass:id/tintImage_controlIV").click()
            if commonFunctions.foundAlert(driver):
                commonFunctions.respondToAlert(driver, 1)
    currentTint = getCurrentTint(driver)
    for i in range(1, 5):
        if i != tint:
            tintStr = "//android.widget.TextView[@text='" + str(i) + "']"
            print(
                len(driver.find_elements(By.XPATH, tintStr)) == 0,
                "Incorrect tint was found. Tint found was " + str(currentTint))
示例#2
0
def checkIfUserIsLoggedIn(driver, loginbool, user):
    """ Check if user needs to be logged in or logged out"""
    # user needs to be logged in
    isLoggedIn = isUserLoggedIn(driver)
    print("Logged in: ", isLoggedIn)
    if loginbool:
        if not isLoggedIn and user == 'RO':
            login(driver, config.users[user]['username'],
                  config.users[user]['password'])
        elif not isLoggedIn:
            loginAndSelectSite(driver, config.users[user]['username'],
                               config.users[user]['password'],
                               config.sites['Default'])

        if common.foundAlert(driver):
            common.respondToAlert(driver, 0)
        if common.foundTour(driver):
            common.exitTour(driver)
        # if len(driver.find_elements(By.ID, "com.view.viewglass:id/view_btnTV")) > 0:
        #     common.navIcon(driver)
    # User needs to be logged out
    else:
        if isLoggedIn:
            if common.foundAlert(driver):
                common.respondToAlert(driver, 0)
            if common.foundTour(driver):
                common.exitTour(driver)
            if len(
                    driver.find_elements(
                        By.ID, "com.view.viewglass:id/view_btnTV")) > 0:
                common.navIcon(driver)
            logout(driver)
            sleep(20)
        else:
            sleep(20)
示例#3
0
    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")
示例#4
0
    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()
示例#5
0
    def testAddNewSceneWithMultipleTintEvents(self):
        auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO')
        auth.loginAndSelectSite(self.driver, config.users['CRUDO']['username'],
                                config.users['CRUDO']['password'],
                                config.sites['Default'])

        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")))
        commonFunctions.addbutton(self.driver)
        if WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.ID, "com.view.viewglass:id/title_scene_addTV"))):
            self.driver.find_element_by_id(
                "com.view.viewglass:id/name_scene_addETV").send_keys(
                    "newscene")
            self.driver.find_element_by_id(
                "com.view.viewglass:id/no_tint_eventTV").click()
        else:
            raiseExceptions("Add New Scene heading is missing")

        for i in range(0, 2):
            self.driver.find_element_by_id(
                "com.view.viewglass:id/add_tint_eventTV").click()
            self.driver.find_element_by_id(
                "com.view.viewglass:id/zone_add_TintEventTV").click()
            if WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located(
                        (By.ID, "com.view.viewglass:id/title_repeatTV"))):
                self.driver.find_elements(
                    By.ID, "com.view.viewglass:id/listItemNameTV")[0].click()
            else:
                raiseExceptions("Zone option led to the wrong screen")
            self.driver.find_element_by_id(
                "com.view.viewglass:id/tintLevel_scene_TintEventTV").click()
            if WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located(
                        (By.ID,
                         "com.view.viewglass:id/title_scene_selectTintTV"))):
                zones_and_scenes.selectRandomTint(self.driver)
            else:
                raiseExceptions("Tint Level option led to the wrong screen")
            commonFunctions.savebutton(self.driver)
        commonFunctions.savebutton(self.driver)
        if commonFunctions.foundAlert(self.driver):
            commonFunctions.respondToAlert(self.driver, 1)
示例#6
0
    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)
示例#7
0
def quickCreateSchedule(driver):
    if WebDriverWait(driver, 10).until(
            EC.presence_of_element_located(
                (By.ID, "com.view.viewglass:id/add_schdIV"))):
        commonFunctions.addbutton(driver)
        changeTint(driver)
        commonFunctions.savebutton(driver)
        WebDriverWait(driver, 30).until(
            EC.presence_of_element_located(
                (By.ID, "com.view.viewglass:id/scheduleTV")))
    else:
        raiseExceptions("add schedule button is missing")

    if commonFunctions.foundAlert(driver):
        commonFunctions.respondToAlert(driver, 1)
        sleep(5)
        commonFunctions.goback(driver)
示例#8
0
    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")
示例#9
0
def logout(driver):
    if common.foundAlert(driver):
        common.respondToAlert(driver, 0)
    common.navIcon(driver)
    if len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/username_navigationTV")) > 0:
        driver.find_element_by_id(
            "com.view.viewglass:id/username_navigationTV").click()
    else:
        raiseExceptions("Missing user profile option in navigation bar")
    if len(
            driver.find_elements(
                By.XPATH, "//android.widget.TextView[@text='Sign Out']")) > 0:
        driver.find_element_by_xpath(
            "//android.widget.TextView[@text='Sign Out']").click()
    else:
        raiseExceptions("Missing Sign Out button")
示例#10
0
def getCurrentTint(driver):
    if len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintImage_controlIV")) > 0:
        driver.find_element_by_id(
            "com.view.viewglass:id/tintImage_controlIV").click()
        if commonFunctions.foundAlert(driver):
            commonFunctions.respondToAlert(driver, 1)
        currentTint = driver.find_element_by_id(
            "com.view.viewglass:id/tintLevelNum_controlTV").text
    elif len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintLevelNum_controlTV")) > 0:
        currentTint = driver.find_element_by_id(
            "com.view.viewglass:id/tintLevelNum_controlTV").text
    else:
        currentTint = selectRandomTint(driver)
        commonFunctions.overridebutton(driver)
    return currentTint
示例#11
0
def clickTintLevelNum(driver):
    if len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintImage_controlIV")) > 0:
        driver.find_element_by_id(
            "com.view.viewglass:id/tintImage_controlIV").click()
        if commonFunctions.foundAlert(driver):
            commonFunctions.respondToAlert(driver, 1)
    elif len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintLevelNum_controlTV")) > 0:
        pass
    else:
        selectRandomTint(driver)
        commonFunctions.overridebutton(driver)
        driver.find_element_by_id(
            "com.view.viewglass:id/tintImage_controlIV").click()
        if commonFunctions.foundAlert(driver):
            commonFunctions.respondToAlert(driver, 1)
示例#12
0
    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")
示例#13
0
def verifyValidTintFound(driver, tint):
    tintStr = "//android.widget.TextView[@text='" + str(tint) + "']"
    if len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintImage_controlIV")) > 0:
        driver.find_element_by_id(
            "com.view.viewglass:id/tintImage_controlIV").click()
        if commonFunctions.foundAlert(driver):
            commonFunctions.respondToAlert(driver, 1)

    currentTint = ""
    if len(
            driver.find_elements(
                By.ID, "com.view.viewglass:id/tintLevelNum_controlTV")) > 0:
        currentTint = driver.find_element_by_id(
            "com.view.viewglass:id/tintLevelNum_controlTV").text
    if driver.find_element_by_id(
            "com.view.viewglass:id/agent_controlTV").text == "IDLE":
        print("Unable to override tint. Mode is IDLE.")
    elif currentTint != str(tint):
        print("Actual tint is:", currentTint)
        raiseExceptions("Displayed tint is incorrect.")
示例#14
0
    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")
示例#15
0
    def testAddTintEventExceptionHandling(self):
        auth.checkIfUserIsLoggedIn(self.driver, 1, 'CRUDO')
        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, 20).until(
            EC.presence_of_element_located(
                (By.ID, "com.view.viewglass:id/scene_headertext")))
        firstScene = self.driver.find_elements(
            By.ID, "com.view.viewglass:id/parent_scene_item")[0]
        firstScene.click()
        WebDriverWait(self.driver, 20).until(
            EC.presence_of_element_located(
                (By.ID, "com.view.viewglass:id/scene_Detail")))

        commonFunctions.editbutton(self.driver)
        if WebDriverWait(self.driver, 20).until(
                EC.presence_of_element_located(
                    (By.ID, "com.view.viewglass:id/add_tint_eventTV"))):
            self.driver.find_element_by_id(
                "com.view.viewglass:id/add_tint_eventTV").click()
        else:
            raiseExceptions("Add Tint Event button is missing")

        commonFunctions.savebutton(self.driver)
        if commonFunctions.foundAlert(self.driver):
            commonFunctions.respondToAlert(self.driver, 1)
        else:
            raiseExceptions(
                "Missing exception handling for invalid input for Add Tint Event"
            )
示例#16
0
    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)
示例#17
0
    def testUIComponentsOfLoginScreen(self):
        """
        Verify the UI components of login screen like logo, user credentials parameters
        """
        if auth.isUserLoggedIn(self.driver):
            if commonFunctions.foundAlert(self.driver):
                commonFunctions.respondToAlert(self.driver, 0)
            auth.logout(self.driver)
            sleep(30)

        if len(
                self.driver.find_elements(
                    By.XPATH, "//android.widget.TextView[@text='view']")) > 0:
            pass
        else:
            raiseExceptions("View logo is missing")
        if len(
                self.driver.find_elements(
                    By.XPATH,
                    "//android.widget.TextView[@text='Dynamic Glass']")) > 0:
            # If statement
            pass
        else:
            raiseExceptions("Dynamic Glass logo is missing")

        if WebDriverWait(self.driver, 30).until(
                EC.presence_of_element_located(
                    (By.XPATH, "//android.widget.EditText[@index='0']"))):
            email = self.driver.find_element_by_xpath(
                "//android.widget.EditText[@index='0']")
            text = email.text
            if text != "Email":
                email.clear()

        if WebDriverWait(self.driver, 5).until(
                EC.presence_of_element_located(
                    (By.XPATH, "//android.widget.EditText[@text='Email']"))):
            pass
        else:
            raiseExceptions(" Enter username field is missing")

        if WebDriverWait(self.driver, 5).until(
                EC.presence_of_element_located(
                    (By.XPATH,
                     "//android.widget.EditText[@text='Password']"))):
            pass
        else:
            raiseExceptions("Enter Password field is missing")

        if len(
                self.driver.find_elements(
                    By.XPATH,
                    "//android.view.View[@content-desc='Remember Me']")) > 0:
            pass
        elif len(
                self.driver.find_elements(By.CLASS_NAME,
                                          "android.widget.CheckBox")) > 0:
            pass
        else:
            raiseExceptions(" Remember me is missing on login screen")

        if len(
                self.driver.find_elements(
                    By.XPATH,
                    "//android.widget.Button[@content-desc='Login']")) > 0:
            pass
        else:
            raiseExceptions("unable to find login button")
示例#18
0
    def testCheckIfSystemIsReadyForTesting(self):
        auth.checkIfUserIsLoggedIn(self.driver, 0, 'CRUDO')
        attempts = 0
        while attempts < 3:
            if len(
                    self.driver.find_elements(
                        By.ID, "com.view.viewglass:id/retry_btn")) > 0:
                self.driver.find_element_by_id(
                    "com.view.viewglass:id/retry_btn").click()

            if len(
                    self.driver.find_elements(
                        By.XPATH,
                        "//android.widget.Button[@content-desc='Login']")) > 0:
                auth.loginOperation(self.driver,
                                    config.users['CRUDO']['username'],
                                    config.users['CRUDO']['password'])
                try:
                    findElements = [
                        ("ID", "com.view.viewglass:id/search_image_view"),
                        ("XPATH",
                         "//android.widget.TextView[@text='Recently Crashed!!!']"
                         ), ("ID", "com.view.viewglass:id/home_controlIV")
                    ]
                    common.waitForElement(self.driver, findElements, 120)
                    # WebDriverWait(self.driver, 120).until(lambda driver: len(driver.find_elements(By.ID,"com.view.viewglass:id/search_image_view")) > 0 or len(driver.find_elements(By.XPATH,"//android.widget.TextView[@text='Recently Crashed!!!']")) > 0 or len(driver.find_elements(By.ID,"com.view.viewglass:id/home_controlIV")) > 0)
                except TimeoutException:
                    print("didn't find anything after 2 minutes")
                    pass

            # after user enters valid credentials and clicks the login button, check if
            # (1) user is led to the Select Site screen, or (2) in the Control screen (RO user), or (3) in Control
            # screen with a 'Recently Crashed' alert. If so, break, and continue (maybe respond to alert)
            if len(
                    self.driver.find_elements(
                        By.ID, "com.view.viewglass:id/search_image_view")) > 0:
                site.selectSite(self.driver, config.sites['Default'])

            if len(
                    self.driver.find_elements(
                        By.ID, "com.view.viewglass:id/home_controlIV")) > 0:
                break
            elif len(
                    self.driver.find_elements(
                        By.XPATH,
                        "//android.widget.TextView[@text='Recently Crashed!!!']"
                    )) > 0:
                common.respondToAlert(self.driver, 0)
                sleep(5)
                break
            elif len(
                    self.driver.find_elements(
                        By.ID, "com.view.viewglass:id/view_btnTV")) > 0:
                self.driver.find_element_by_id(
                    "com.view.viewglass:id/view_btnTV").click()
                break
            elif common.foundTour(self.driver):
                common.exitTour(self.driver)
                break
            elif 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:
                raiseExceptions("Site is not reachable at the moment")
            else:
                attempts += 1
                self.driver.close_app()
                self.driver.launch_app()
                sleep(20)

            if common.foundTour(self.driver):
                common.exitTour(self.driver)
            if len(
                    self.driver.find_elements(
                        By.ID, "com.view.viewglass:id/view_btnTV")) > 0:
                self.driver.find_element_by_id(
                    "com.view.viewglass:id/view_btnTV").click()
                sleep(5)

        if attempts == 3:
            raiseExceptions("Unable to login after 3 tries")
示例#19
0
    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")
示例#20
0
    def testUIUpdateAfterApplyingSceneSchedule(self):
        """
         Create a scene schedule from scene screen and  verify the entry with scene schedule in  LiveView
        """
        auth.checkIfUserIsLoggedIn(self.driver, 1, 'CRUDO')
        if len(
                self.driver.find_elements(
                    By.ID, "com.view.viewglass:id/title_LiveViewTV")) <= 0:
            commonFunctions.navIcon(self.driver)
            if WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located(
                        (By.ID,
                         "com.view.viewglass:id/navigation_live_viewTV"))):
                self.driver.find_element_by_id(
                    "com.view.viewglass:id/navigation_live_viewTV").click()
            else:
                raiseExceptions(
                    "LiveView option in navigation menu is missing")
        commonFunctions.checkLiveViewAccess(self.driver)

        commonFunctions.navIcon(self.driver)
        if WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.ID, "com.view.viewglass:id/navigation_scheduleTV"))):
            self.driver.find_element_by_id(
                "com.view.viewglass:id/navigation_scheduleTV").click()
        else:
            raiseExceptions("Schedule option in navigation menu is missing")

        startTime = ""
        endTime = ""
        if WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.ID, "com.view.viewglass:id/scheduleTV"))):
            commonFunctions.addbutton(self.driver)
            control.changeTint(self.driver)
            self.driver.find_element_by_id(
                "com.view.viewglass:id/zone_scene_sel_selClsTypeTV").click()
            self.driver.find_element_by_xpath(
                "//android.widget.TextView[@text='SCENE']").click()
            startTime = datetime.strptime(
                self.driver.find_element_by_id(
                    "com.view.viewglass:id/starts_value_schdSceneTintTV").text,
                '%I:%M %p')
            endTime = datetime.strptime(
                self.driver.find_element_by_id(
                    "com.view.viewglass:id/ends_value_schdSceneTintTV").text,
                '%I:%M %p')
            commonFunctions.savebutton(self.driver)
        if commonFunctions.foundAlert(self.driver):
            commonFunctions.respondToAlert(self.driver, 1)
            print("Unable to create scene")
            commonFunctions.goback(self.driver)

        commonFunctions.navIcon(self.driver)
        if WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.ID, "com.view.viewglass:id/navigation_live_viewTV"))):
            self.driver.find_element_by_id(
                "com.view.viewglass:id/navigation_live_viewTV").click()
        else:
            raiseExceptions("LiveView option in navigation menu is missing")

        timeOfMostRecentActivity = ""
        if WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.ID, "com.view.viewglass:id/time_liveViewTV"))):
            self.driver.find_elements(
                By.ID, "com.view.viewglass:id/time_liveViewTV")[0].click()
            timeOfMostRecentActivity = datetime.strptime(
                self.driver.find_elements(
                    By.ID, "com.view.viewglass:id/time_liveViewTV")[0].text,
                '%I:%M %p')
        else:
            raiseExceptions("Bug: there are no tint activities in the list")

        if startTime < timeOfMostRecentActivity and timeOfMostRecentActivity < endTime:
            raiseExceptions(
                "Bug: The recently applied tint was not added to the list of tint activities"
            )