def test_inSeq_selected(self):
        """
        Asserts each outlet is in-sequence
        This function clicks on each outlet and make sure the check
        box is checked. If it is already checked, then it continues to the next
        outlet
        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        inSeqInput = "//div[8]/div[2]/form[1]/p[1]/input"
        outletsWithStateOff = self.driver.find_elements_by_class_name("state-off")

        numOfOutletBox = len(outletBoxList)
        numOutletsStateOff = len(outletsWithStateOff)

        if numOutletsStateOff == numOfOutletBox:
            assert numOutletsStateOff == numOfOutletBox
            print "\nAll outlets are already off"
            return

        index = 2
        for outletBox in outletBoxList:
            outletCtrlStr = ".//*[@id='outletControl']/div[{0}]/div[1]".format(index)
            time.sleep(5)
            driver.wait_and_click(outletCtrlStr, XPATH)
            time.sleep(3)

            if not driver.is_element_selected(inSeqInput, XPATH):
                driver.wait_for_visibility(inSeqInput, XPATH)
                driver.element_click(inSeqInput, XPATH)
                assert driver.is_element_selected(inSeqInput, XPATH) == True
                driver.wait_and_click(outlet_save_btn(), XPATH)
                driver.wait_and_click(close_btn_msg(), XPATH)
            else:
                driver.wait_and_click(outlet_save_btn(), XPATH)
                driver.wait_and_click(close_btn_msg(), XPATH)

            if 'in-sequence' in outletBox.get_attribute(ClASS):
                assert 'in-sequence' in outletBox.get_attribute(ClASS)

            index += 1
示例#2
0
    def test_authentication(self):
        driver = SeleniumDriver(self.driver)
        username = "******"
        password = "******"
        confirmPass = "******"
        showPass = "******"  # show password

        self.open_email_settings()
        time.sleep(3)
        self.default_ip_email_rep()
        time.sleep(3)

        driver.wait_and_click("authReq", ID)
        driver.wait_and_click(save_btn(), XPATH)

        assert self.has_error(username) == True
        assert self.has_error(password) == True
        assert self.has_error(confirmPass) == True
        assert self.is_hidden_string(notify_msg()) == False

        driver.element_click("btnOk", ID)

        time.sleep(3)
        driver.wait_for_visibility(password, XPATH)
        driver.get_element(password, XPATH)
        driver.send_input(password, XPATH, "Test123")

        driver.get_element(confirmPass, XPATH)
        driver.send_input(confirmPass, XPATH, "Test123")

        driver.element_click(showPass, XPATH)
        if driver.is_element_selected(showPass, XPATH):
            # if 'hidden' is in the password class
            assert self.is_hidden_string(password) == True

            time.sleep(3)
            driver.element_click(showPass, XPATH)

            # if 'hidden' is not in the password class
            assert self.is_hidden_string(password) == False

        driver.wait_and_click(cancel_btn(), XPATH)

        time.sleep(3)
        self.restore_email_settings()
    def test_power_cycle_until_recovery(self):

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        powerCycUntilRec = "//div[8]/div[2]/form[2]/select/option[contains(@value, '6')]"
        ipAddressInputElem = '//div[8]/div[2]/form[2]/p[1]/input'
        freqInputElem = "//div[8]/div[2]/form[2]/p[2]/input"
        retriesInputElem = "//div[8]/div[2]/form[2]/p[3]/input"
        selectOptions = "//div[8]/div[2]/form[2]/select"
        cycleDelayElem = "//div[8]/div[2]/form[2]/p[6]/input"
        frequency = 30
        retries = 2
        cycleDelay = 3
        waitTime = (frequency * retries) * 2

        index = 2
        for outletBox in outletBoxList:
            outletCtrlStr = ".//*[@id='outletControl']/div[{0}]/div[1]".format(
                index)
            outletOn = "//*[@id='outletControl']/div[{0}]/div[contains(@class, 'state-on')]".format(
                index)
            autoPingTitle = "//*[@id='outletControl']/div[{0}]/h6".format(
                index)

            time.sleep(5)
            driver.wait_and_click(outletCtrlStr, XPATH)

            self.ctrl_device_power()  # turn outlet off in the control device

            ipAddresses = get_ip_addresses()
            ipAddressToPing = ipAddresses[2]  # ip address to ping

            if self.is_on(outletFace) is False:
                driver.element_click(stateBtn, XPATH)
                driver.element_click("btnOk", ID)
                driver.wait_and_click(close_btn_msg(), XPATH)
                time.sleep(5)
                driver.get_element(outletCtrlStr, XPATH)
                driver.wait_and_click(outletCtrlStr, XPATH)

            if not self.is_on(enableBtn):
                driver.wait_and_click(enableBtn, XPATH)

            # input for ip address to ping, frequency, and retries
            driver.send_input(ipAddressInputElem, XPATH, ipAddressToPing)
            driver.send_input(freqInputElem, XPATH, frequency)
            driver.send_input(retriesInputElem, XPATH, retries)

            time.sleep(3)
            driver.wait_and_click(selectOptions, XPATH)

            if driver.is_element_selected(powerCycUntilRec, XPATH):
                driver.wait_and_click(outlet_save_btn(), XPATH)
            else:
                driver.wait_and_click(powerCycUntilRec, XPATH)
                self.driver.find_element_by_xpath(powerCycUntilRec).send_keys(
                    Keys.ENTER)
                driver.wait_until_clickable(cycleDelayElem, XPATH)
                driver.send_input(cycleDelayElem, XPATH, cycleDelay)
                driver.wait_and_click(outlet_save_btn(), XPATH)

            # in case the notification message pops up
            notifyDisplayed = self.driver.find_element_by_xpath(
                notify_msg()).is_displayed()
            if notifyDisplayed:
                driver.element_click("btnOk", ID)

            # verify if "AutoPing Failed" is in the autoPing title
            driver.wait_text_to_be_present_in_elem(autoPingTitle, XPATH,
                                                   'AutoPing Failed', waitTime)
            autoPingTitleClass = driver.get_element_attribute(
                autoPingTitle, XPATH, "title")
            assert autoPingTitleClass == "AutoPing Failed"

            self.ctrl_device_power(
            )  # turn outlet back on in the control device

            # verify that the outlet in the UUT is on, wait cycle delay
            # then verify that the outlet turned off
            driver.wait_for_visibility(outletOn, XPATH)
            assert self.is_on(outletCtrlStr) == True
            time.sleep(cycleDelay + 1)
            assert self.is_on(outletCtrlStr) == False

            # gets class again and verify if "AutoPing Replied" is in the autoPing title
            driver.wait_text_to_be_present_in_elem(autoPingTitle, XPATH,
                                                   'AutoPing Replied',
                                                   waitTime)
            autoPingTitleClass = driver.get_element_attribute(
                autoPingTitle, XPATH, "title")
            assert autoPingTitleClass == "AutoPing Replied"

            # open outlet in UUT, turn it back on, change ip address to default, & save changes
            time.sleep(3)
            self.change_ip_address_to_default(outletCtrlStr,
                                              ipAddressInputElem)

            index += 1