def test_frequency_success_msg(self):
        """
        Verify that the Success message appears
        Verify that the outlet shrinks out edit mode and return to original location

        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        freqInputElem = "//div[8]/div[2]/form[2]/p[2]/input"
        ip_addr_ping = "//div[8]/div[2]/form[2]/p[1]/input"
        enableBtn = "//div[8]/div[2]/form[1]/button[2]"
        frequency = 30

        for outletBox in outletBoxList:
            time.sleep(5)
            outletBox.click()

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

            driver.send_input(ip_addr_ping, XPATH, "8.8.8.8")
            driver.send_input(freqInputElem, XPATH, frequency)
            driver.wait_and_click(outlet_save_btn(), XPATH)

            time.sleep(2)
            if driver.is_element_present(close_btn_msg(), XPATH):
                assert self.is_hidden_string(success_msg()) == False
                driver.wait_and_click(close_btn_msg(), XPATH)

            time.sleep(1)
            assert driver.is_element_present("//div[8]", XPATH) == False
    def test_outlet_cycle(self):
        """
        Verify that the cycle input is between 1 - 999
        Verify “Are you sure…” message appears
        Verify success message appears
        Verify that the outlet face has changed color
        Verify that the outlet shrinks out of edit mode

        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        cycleNum = 10  # cycle number in seconds
        cycleInput = '//div[8]/div[2]/form[1]/p[2]/input'
        startCycleBtn = "//div[8]/div[2]/form[1]/p[2]/button"
        outletEditMode = "//div[8]"

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

            outletBox.click()
            driver.wait_until_clickable(cycleInput, XPATH)
            driver.send_input(cycleInput, XPATH, cycleNum)

            # Verify that the cycle input is between 1 - 999
            cycleInputVal = driver.get_element_attribute(
                cycleInput, XPATH, VALUE)
            assert 1 <= int(cycleInputVal) <= 999

            driver.element_click(startCycleBtn, XPATH)

            # Verify “Are you sure…” message appears
            driver.wait_for_visibility(notify_msg(), XPATH)
            assert self.is_hidden_string(notify_msg()) == False

            driver.element_click("btnOk", ID)

            # Verify success message appears
            time.sleep(1)
            if driver.is_element_present(success_msg(), XPATH):
                assert self.is_hidden_string(success_msg()) == False

            # Verify that the outlet face has changed color to red
            time.sleep(5)
            driver.get_element(outletCtrlStr, XPATH)
            assert self.is_on(outletCtrlStr) == False

            # Verify that the outlet face has changed color to green
            time.sleep(cycleNum)
            driver.get_element(outletCtrlStr, XPATH)
            assert self.is_on(outletCtrlStr) == True

            # Verify that the outlet shrinks out of edit 0mode
            assert driver.is_element_present(outletEditMode, XPATH) == False

            index += 1
Exemple #3
0
    def test_power_state_verify_changed(self):
        """
        Verify that the switch and outlet face change state
        Verify that a success message appears
        Verify that the outlet shrinks out of edit mode

        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        powerStateBtn = '//div[8]/div[2]/form[1]/button[1]'
        outletEditMode = "//div[8]"

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

            if self.is_on(powerStateBtn):
                powerState = True
            else:
                powerState = False

            driver.wait_and_click(powerStateBtn, XPATH)
            driver.wait_and_click("btnOk", ID)

            time.sleep(1)
            if driver.is_element_present(close_btn_msg(), XPATH):
                driver.wait_and_click(close_btn_msg(), XPATH)
                assert self.is_hidden_string(success_msg()) == False

            time.sleep(1)
            assert driver.is_element_present(outletEditMode, XPATH) == False

            driver.element_click(outletCtrlStr, XPATH)

            if powerState:
                if self.is_on(powerStateBtn):
                    assert powerState == True
            else:
                assert powerState == False

            driver.wait_and_click(outlet_cancel_btn(), XPATH)

            index += 1

        time.sleep(3)
        self.seq_up()
    def test_edit_cancel_btn(self):
        """
        Verification of Outlet Edit mode and Cancel Button Functionality
        verify that the outlet has the “guitarSolo” class
        verify that the outlet no longer has the “guitarSolo” class

        """
        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        outletEditMode = "//div[8]"

        index = 2
        for outletBox in outletBoxList:
            expectedOpGood = True
            time.sleep(5)
            outletBox.click()

            outletElemClass = driver.get_element_attribute(outletEditMode, XPATH, ClASS)

            if 'guitarSolo' in outletElemClass:
                assert expectedOpGood == True

            driver.wait_and_click(outlet_cancel_btn(), XPATH)

            time.sleep(1)
            assert driver.is_element_present(outletEditMode, XPATH) == False

            index += 1
Exemple #5
0
    def test_power_state_btn_notify_msg(self):
        """
        Verifies that a popup comes up with an Are you sure… message.
        Look for the DOM element “notify”

        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        powerStateBtn = '//div[8]/div[2]/form[1]/button[1]'

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

            if self.is_on(powerStateBtn):
                driver.wait_and_click(powerStateBtn, XPATH)

                assert self.is_hidden_string(notify_msg()) == False
                driver.wait_and_click("btnOk", ID)

                time.sleep(1)
                if driver.is_element_present(success_msg(), XPATH):
                    assert self.is_hidden_string(success_msg()) == False
                    time.sleep(3)
            else:
                driver.wait_and_click(outlet_cancel_btn(), XPATH)

            i += 1

        time.sleep(3)
        self.seq_up()
    def change_ip_address_to_default(self, outletCtrlStr, ipAddressInputElem):
        driver = SeleniumDriver(self.driver)
        driver.get_element(outletCtrlStr, XPATH)
        driver.wait_and_click(outletCtrlStr, XPATH)
        driver.send_input(ipAddressInputElem, XPATH, "8.8.8.8")
        driver.wait_and_click(outlet_save_btn(), XPATH)

        time.sleep(1)
        if driver.is_element_present(success_msg(), XPATH):
            driver.wait_and_click(close_btn_msg(), XPATH)
        else:
            time.sleep(3)
Exemple #7
0
    def default_ip_email_rep(self):
        driver = SeleniumDriver(self.driver)
        emailIpHost = "//*[@id='emailSettings']/div[1]/p[1]/input"
        senderEmail = "//*[@id='emailSettings']/div[1]/p[2]/input"
        addRepBtn = "//*[@id='emailSettings']/div[3]/p[2]/button"  # add recipient button
        repName = "//*[@id='emailSettings']/div[3]/div[2]/p[1]/input"
        repEmail = "//*[@id='emailSettings']/div[3]/div[2]/p[2]/input"
        recpEntry = "//*[@id='emailSettings']/div[3]/div[2]"

        if not driver.is_element_present(recpEntry, XPATH):
            driver.wait_and_click(addRepBtn, XPATH)
            time.sleep(3)

        driver.send_input(emailIpHost, XPATH, "12.12.12.12")
        driver.send_input(senderEmail, XPATH, "*****@*****.**")

        driver.send_input(repName, XPATH, "Test Test")
        driver.send_input(repEmail, XPATH, "*****@*****.**")
    def test_outlet_name_length(self):
        """
        function to test outlets' name
        outlet name can only accept up to 50 characters (letters, digits, and special characters)

        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        outletNameElement = '//div[8]/div[2]/input'

        # Random characters with a length of 50 to test outlet's name
        randomChars = 'g#QUfjeTakWbxHCS*6RQ579Wq6sBV3AT?#T!DrZ6#yJpbZzC$@'

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

            driver.wait_and_click(outlet_save_btn(), XPATH)

            time.sleep(2)
            if driver.is_element_present(close_btn_msg(), XPATH):
                assert self.is_hidden_string(success_msg()) == False
                driver.wait_and_click(close_btn_msg(), XPATH)

            time.sleep(5)
            driver.wait_and_click(outletCtrlStr, XPATH)
            inputValue = driver.get_element_attribute(outletNameElement, XPATH,
                                                      VALUE)

            #  assert input
            assert 50 >= len(inputValue) >= 1

            driver.wait_and_click(outlet_cancel_btn(), XPATH)

            i += 1

        time.sleep(3)
        self.restore_outlet_defaults()
    def test_power_off(self):
        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        powerOffOption = "//div[8]/div[2]/form[2]/select/option[contains(@value, '1')]"
        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"
        frequency = 30
        retries = 2
        waitTime = (frequency * retries) * 2

        index = 2
        for outletBox in outletBoxList:
            outletCtrlStr = ".//*[@id='outletControl']/div[{0}]/div[1]".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 not self.is_on(outletFace):
                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
            time.sleep(3)
            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(powerOffOption, XPATH):
                driver.wait_and_click(outlet_save_btn(), XPATH)
            else:
                driver.wait_and_click(powerOffOption, XPATH)
                self.driver.find_element_by_xpath(powerOffOption).send_keys(
                    Keys.ENTER)
                driver.wait_and_click(outlet_save_btn(), XPATH)

            # in case the notification message to confirm changes 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

            # 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)
            driver.get_element(autoPingTitle, XPATH)
            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)
            driver.get_element(outletCtrlStr, XPATH)
            driver.element_click(outletCtrlStr, XPATH)
            driver.wait_and_click(stateBtn, XPATH)
            driver.element_click("btnOk", ID)

            time.sleep(1)
            if driver.is_element_present(close_btn_msg(), XPATH):
                driver.element_click(close_btn_msg(), XPATH)
            else:
                time.sleep(3)

            time.sleep(3)
            self.change_ip_address_to_default(outletCtrlStr,
                                              ipAddressInputElem)

            index += 1