def test_outlet_name_blank(self):
        """
        Verify that the name input box has a red border
        after changing the name to blank/empty

        """

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

        for outletBox in outletBoxList:
            time.sleep(5)
            outletBox.click()
            driver.wait_until_clickable(outletNameElement, XPATH)
            driver.get_element(outletNameElement, XPATH).clear()

            driver.wait_and_click(outlet_save_btn(), XPATH)

            assert self.is_hidden_string(notify_msg()) == False

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

            assert self.has_error(outletNameElement) == True
    def test_cycle_invalid_input(self):
        """
        - Set the Cycle Delay to zero (0) and then click on the Start Cycle button
        - Verify that a warning notification appears letting
        you know the valid range of cycle delay values
        - Verify that the input has a red border to show an error

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

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

            if self.is_on(outletCtrlStr) is False:
                index += 1
            else:
                outletBox.click()
                driver.wait_until_clickable(cycleInput, XPATH)
                driver.send_input(cycleInput, XPATH, cycleNum)

                driver.element_click(startCycleBtn, XPATH)

                assert self.is_hidden_string(notify_msg()) == False

                driver.element_click("btnOk", ID)

                assert self.has_error(cycleInput) == True
                driver.wait_and_click(outlet_cancel_btn(), XPATH)
Example #3
0
    def test_sender_email(self):
        driver = SeleniumDriver(self.driver)
        send_email_input = "//*[@id='emailSettings']/div[1]/p[2]/input"
        invalid_emails = [
            'test@@test.com', '*****@*****.**', '@.com', 'test', 'test.com',
            '[email protected]', ''
        ]

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

        for email in invalid_emails:
            driver.wait_until_clickable(send_email_input, XPATH)
            driver.send_input(send_email_input, XPATH, email)
            driver.wait_and_click(save_btn(), XPATH)

            assert self.has_error(send_email_input) == True
            assert self.is_hidden_string(notify_msg()) == False

            driver.element_click("btnOk", ID)
        driver.wait_and_click(cancel_btn(), XPATH)

        time.sleep(3)
        self.restore_email_settings()
    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
Example #5
0
    def test_ip_host_name(self):
        driver = SeleniumDriver(self.driver)
        emailIpHost = "//*[@id='emailSettings']/div[1]/p[1]/input"
        inputBox = "//*[@id='emailSettings']/div[1]/p[1]/input"
        invalidIpHostNames = [
            '0.8.8.8', '8.8.8.0', '255.8.8.8', '20.255.90', '8.8.8',
            '8.8.8.8.8', 'exchange.map'
        ]

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

        for name in invalidIpHostNames:
            driver.wait_until_clickable(emailIpHost, XPATH)
            driver.send_input(emailIpHost, XPATH, name)
            driver.wait_and_click(save_btn(), XPATH)

            ipHostVal = driver.get_element_attribute(emailIpHost, XPATH, VALUE)
            ipNodes = ip_nodes(ipHostVal)
            hostNodes = host_nodes(ipHostVal)

            assert self.is_hidden_string(notify_msg()) == False

            driver.element_click("btnOk", ID)

            assert self.has_error(inputBox) == True

            ipInputClass = driver.get_element_attribute(
                emailIpHost, XPATH, ClASS)

            expectedOpGood = True

            if name.startswith("0"):
                assert starts_with_zero(ipHostVal,
                                        ipInputClass) == expectedOpGood
            elif name.endswith("0"):
                assert ends_with_zero(ipHostVal,
                                      ipInputClass) == expectedOpGood
            elif "255" in name:
                assert node_255(ipHostVal, ipInputClass) == expectedOpGood
            elif len(ipNodes) < 4:
                assert short_ip_node_length(ipHostVal,
                                            ipInputClass) == expectedOpGood
            elif len(hostNodes) < 3:
                assert short_host_node_length(ipHostVal,
                                              ipInputClass) == expectedOpGood
            else:
                assert long_ip_node_length(ipHostVal,
                                           ipInputClass) == expectedOpGood

        driver.wait_and_click(cancel_btn(), XPATH)

        time.sleep(3)
        self.restore_email_settings()
Example #6
0
    def test_network(self):
        driver = SeleniumDriver(self.driver)
        DHCPCheckBox = "//*[@id='networkSettings']/div[3]/input"
        HTTPPort = "//*[@id='networkHttpPort']"
        network_ip_address = "//*[@id='networkIPAddress']"
        subnet_mask = "//*[@id='networkSettings']/p[2]/input"
        gateway = "//*[@id='networkSettings']/p[3]/input"
        dns_1 = ".//*[@id='networkSettings']/p[4]/input"
        dns_2 = "//*[@id='networkSettings']/p[5]/input"
        invalid_ips = [
            '0.8.8.8', '8.8.8.0', '255.8.8.8', '20.255.80', '8.8.8',
            '8.8.8.8.8'
        ]

        self.open_network_settings()
        time.sleep(3)

        driver.send_input(HTTPPort, XPATH, "---")
        driver.wait_and_click(save_btn(), XPATH)

        assert self.is_hidden_string(notify_msg()) == False

        driver.wait_and_click("btnOk", ID)

        driver.wait_and_click(DHCPCheckBox, XPATH)

        for ip in invalid_ips:
            driver.wait_until_clickable(network_ip_address, XPATH)
            driver.send_input(network_ip_address, XPATH, ip)
            driver.send_input(subnet_mask, XPATH, ip)
            driver.send_input(gateway, XPATH, ip)
            driver.send_input(dns_1, XPATH, ip)
            driver.send_input(dns_2, XPATH, ip)
            driver.wait_and_click(save_btn(), XPATH)

            assert self.has_error(network_ip_address) == True
            assert self.is_hidden_string(notify_msg()) == False

            driver.element_click("btnOk", ID)
        driver.wait_and_click(cancel_btn(), XPATH)

        time.sleep(3)
        self.restore_network_settings()
Example #7
0
    def test_port_number(self):
        driver = SeleniumDriver(self.driver)
        port_input = "//*[@id='emailSettings']/div[1]/p[3]/input"
        invalid_ports = ['test', 'test123', '---']

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

        for port in invalid_ports:
            driver.wait_until_clickable(port_input, XPATH)
            driver.send_input(port_input, XPATH, port)
            driver.wait_and_click(save_btn(), XPATH)

            assert self.has_error(port_input) == True
            assert self.is_hidden_string(notify_msg()) == False

            driver.element_click("btnOk", ID)
        driver.wait_and_click(cancel_btn(), XPATH)

        time.sleep(3)
        self.restore_email_settings()
    def test_outlet_name_not_changed(self):
        """
        Click on the outlet
        verify that the name has not changed after clicking the cancel btn.

        """

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

        randomInput = "Outlet Name"

        index = 2
        for outletBox in outletBoxList:
            outletBoxStr = ".//*[@id='outletControl']/div[{0}]".format(index)
            time.sleep(5)
            outletBox.click()
            driver.wait_until_clickable(outletNameElement, XPATH)
            driver.send_input(outletNameElement, XPATH, randomInput)

            driver.wait_and_click(outlet_cancel_btn(), XPATH)

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

            driver.wait_until_clickable(outletNameElement, XPATH)
            driver.get_element(outletNameElement, XPATH)

            inputVal = driver.get_element_attribute(outletNameElement, XPATH,
                                                    VALUE)

            assert inputVal != randomInput

            driver.wait_and_click(outlet_cancel_btn(), XPATH)
            index += 1
    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
Example #10
0
    def test_ip_address_ping(self):
        """
            Asserts that the ip address input value is valid
            test_operation.py contains all the functionality for each test
            Tests:
                '8.8.8.8' -> Valid IP address that works
                '0.8.8.8' -> Cannot start with 0
                '8.8.8.0' -> Cannot end with 0
                '255.8.8.8' -> Each node must be less than 255 and greater than 0
                '.8.8.8' -> A node cannot be empty
                '8.8.8' -> There must be exactly 4 nodes separated by dots (periods)
        """

        driver = SeleniumDriver(self.driver)
        outletBoxList = self.driver.find_elements_by_xpath(outlet_box_xpath())
        enabledBtn = '//div[8]/div[2]/form[1]/button[2]'
        ipAddressInputElem = '//div[8]/div[2]/form[2]/p[1]/input'
        invalid_ips = [
            '0.8.8.8', '8.8.8.0', '255.8.8.8', '20.255.90', '8.8.8',
            '8.8.8.8.8'
        ]

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

            if self.is_on(enabledBtn) is False:
                driver.wait_and_click(enabledBtn, XPATH)

            driver.wait_until_clickable(enabledBtn, XPATH)
            driver.get_element(enabledBtn, XPATH)

            if self.is_on(enabledBtn):
                for ip in invalid_ips:
                    driver.wait_until_clickable(ipAddressInputElem, XPATH)
                    driver.send_input(ipAddressInputElem, XPATH, ip)

                    driver.wait_and_click(outlet_save_btn(), XPATH)

                    ipNumVal = driver.get_element_attribute(
                        ipAddressInputElem, XPATH, VALUE)
                    nodes = ip_nodes(ipNumVal)

                    if self.is_hidden_string(notify_msg()) is False:
                        expectedOpGood = True

                        driver.element_click("btnOk", ID)
                        ipInputClass = driver.get_element_attribute(
                            ipAddressInputElem, XPATH, ClASS)

                        if ip.startswith("0"):
                            assert starts_with_zero(
                                ipNumVal, ipInputClass) == expectedOpGood
                        elif ip.endswith("0"):
                            assert ends_with_zero(
                                ipNumVal, ipInputClass) == expectedOpGood
                        elif "255" in ip:
                            assert node_255(ipNumVal,
                                            ipInputClass) == expectedOpGood
                        elif len(nodes) < 4:
                            assert short_ip_node_length(
                                ipNumVal, ipInputClass) == expectedOpGood
                        else:
                            assert long_ip_node_length(
                                ipNumVal, ipInputClass) == expectedOpGood

                        time.sleep(1)

                driver.send_input(ipAddressInputElem, XPATH, "8.8.8.8")
                driver.wait_and_click(outlet_save_btn(), XPATH)
                driver.wait_and_click(close_btn_msg(), XPATH)