class UserPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
        self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        self.login_button.click()
        time.sleep(5)

    def admin_tab(self):
        self.admin = self.driver.find_element(By.XPATH, '//*[@id="menu_admin_viewAdminModule"]').click()
        time.sleep(3)
        return self

    def add_btn(self):
        self.add = Button(By.ID, 'btnAdd').click()
        time.sleep(3)

    def add_user(self):
        self.user_role = self.driver.find_element(By.XPATH, '//*[@id="systemUser_userType"]/option[@value=2]').click()
        time.sleep(2)
        self.employee_name = self.driver.find_element(By.XPATH, '//*[@id="systemUser_employeeName_empName"]').send_keys('Robert Craig')
        time.sleep(2)
        self.username = self.driver.find_element(By.XPATH, '//*[@id="systemUser_userName"]').send_keys('robert.craig')
        time.sleep(2)
        self.status = self.driver.find_element(By.XPATH, '//*[@id="systemUser_status"]/option[@value=1]').click()
        time.sleep(2)
        self.password = self.driver.find_element(By.XPATH, '//*[@id="systemUser_password"]').send_keys('Passw0rd123')
        time.sleep(2)
        self.confirm_pass = self.driver.find_element(By.XPATH, '//*[@id="systemUser_confirmPassword"]').send_keys('Passw0rd123')
        time.sleep(2)
        self.save_button = Button(By.XPATH, '//*[@id="btnSave"]').click()
        time.sleep(5)
Пример #2
0
class AddEmployeePageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
        self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        self.login_button.click()
        time.sleep(5)

    def pim_tab(self):
        self.pim_click = self.driver.find_element(
            By.XPATH, '//*[@id="menu_pim_viewPimModule"]').click()
        time.sleep(3)
        return self

    def add_employee(self):
        self.employee = self.driver.find_element(
            By.XPATH, '//*[@id="menu_pim_addEmployee"]').click()
        time.sleep(3)
        return self

    def empl_details(self):
        self.first_name = self.driver.find_element(
            By.XPATH, '//*[@id="firstName"]').send_keys('Steve')
        self.last_name = self.driver.find_element(
            By.XPATH, '//*[@id="lastName"]').send_keys('Smith')
        self.save_btn = Button(By.XPATH, '//*[@id="btnSave"]').click()
        time.sleep(3)
        return self
Пример #3
0
class RebootSystemPage(BasePageObject):
    """Selenium Page Object Model: RebootSystemPage."""

    # Page Elements
    current_settings_radio = InputRadio(
        By.XPATH,
        "//input[@name='sReboot' and @type='radio' and @value='Current']")
    factory_settings_radio = InputRadio(
        By.XPATH,
        "//input[@name='sReboot' and @type='radio' and @value='Default']")
    reboot_now_button = Button(By.NAME, "submitbnt")

    # TODO (#4074): Add Support for scheduling a reboot

    def open_page(self):
        """Navigate menus to open SNMP configuration page."""
        menu = MenuNavigator(self.driver_wrapper)
        menu.open_sysmain_reboot_system()

    def reboot(self):
        """Trigger router reboot with current configuration."""
        self.open_page()
        self.current_settings_radio.click()
        self.reboot_now_button.click()

    def reboot_reset_to_factory_configuration(self):
        """***CAUTION*** Trigger router reboot back to factory default configuration."""
        self.open_page()
        self.factory_settings_radio.click()
        self.reboot_now_button.click()
Пример #4
0
class LoginPageObject(PageObject):
    title = Text(By.ID, 'title')
    username = InputText(By.XPATH, '//input[0]')
    password = InputText(By.ID, 'password')
    language = Select(By.ID, 'language')
    login = Button(By.ID, 'login')
    menu = Menu(By.ID, 'menu')
Пример #5
0
 def add_user(self):
     self.user_role = self.driver.find_element(
         By.XPATH,
         '//*[@id="systemUser_userType"]/option[@value=2]').click()
     time.sleep(2)
     self.employee_name = self.driver.find_element(
         By.XPATH, '//*[@id="systemUser_employeeName_empName"]').send_keys(
             'Robert Craig')
     time.sleep(2)
     self.username = self.driver.find_element(
         By.XPATH,
         '//*[@id="systemUser_userName"]').send_keys('robert.craig')
     time.sleep(2)
     self.status = self.driver.find_element(
         By.XPATH, '//*[@id="systemUser_status"]/option[@value=1]').click()
     time.sleep(2)
     self.password = self.driver.find_element(
         By.XPATH,
         '//*[@id="systemUser_password"]').send_keys('Passw0rd123')
     time.sleep(2)
     self.confirm_pass = self.driver.find_element(
         By.XPATH,
         '//*[@id="systemUser_confirmPassword"]').send_keys('Passw0rd123')
     time.sleep(2)
     self.save_button = Button(By.XPATH, '//*[@id="btnSave"]').click()
     time.sleep(5)
Пример #6
0
 def leave_details(self):
     self.empl_name = self.driver.find_element(
         By.XPATH,
         '//*[@id="assignleave_txtEmployee_empName"]').send_keys('J')
     time.sleep(2)
     self.list = self.driver.find_element(
         By.XPATH, '/html/body/div[6]/ul/li[1]').click()
     time.sleep(2)
     self.leave_type = self.driver.find_element(
         By.XPATH,
         '//*[@id="assignleave_txtLeaveType"]/option[@value=1]').click()
     time.sleep(2)
     self.from_date = self.driver.find_element(
         By.XPATH, '//*[@id="assignleave_txtFromDate"]').click()
     time.sleep(2)
     self.start_date = self.driver.find_element(
         By.XPATH,
         '//*[@id="ui-datepicker-div"]/table/tbody/tr[4]/td[4]/a').click()
     time.sleep(2)
     self.to_date = self.driver.find_element(
         By.XPATH, '//*[@id="assignleave_txtToDate"]').click()
     time.sleep(5)
     self.end_date = self.driver.find_element(
         By.XPATH,
         '//*[@id="ui-datepicker-div"]/table/tbody/tr[5]/td[5]/a').click()
     time.sleep(5)
     self.button = Button(By.XPATH, '//*[@id="assignBtn"]').click()
     time.sleep(5)
Пример #7
0
 def empl_details(self):
     self.first_name = self.driver.find_element(
         By.XPATH, '//*[@id="firstName"]').send_keys('Steve')
     self.last_name = self.driver.find_element(
         By.XPATH, '//*[@id="lastName"]').send_keys('Smith')
     self.save_btn = Button(By.XPATH, '//*[@id="btnSave"]').click()
     time.sleep(3)
     return self
    def back_btn(self):
        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.back_btn = Button(By.XPATH, '//*[@id="btnBack"]').click()

        time.sleep(3)

        return self
Пример #9
0
    def create_account(self):
        try:
            self.email = self.driver.find_element(By.XPATH, '//*[@id="email_create"]').send_keys('*****@*****.**')
            self.submit = Button(By.ID, 'SubmitCreate').click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
            return None
Пример #10
0
    def init_page_elements(self):
        """ Open page elements

        :returns: this page object instance
        """
        self.genre = Button(By.XPATH, '//*[@text="Songs by genre"]', wait=True)
        self.rock = Button(By.XPATH, '//*[@text="Rock songs"]', wait=True)
        self.song = Button(By.XPATH, '//*[@text="Silent Partner"]', wait=True)
Пример #11
0
class LoginPage(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()
        


    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)
Пример #12
0
class LoginPage(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        time.sleep(5)
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)
Пример #13
0
    def fill_form(self):
        self.fname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_firstName"]').send_keys("Samkelo")
        self.mname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_middleName"]').send_keys("Sam")
        self.lname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_lastName"]').send_keys("Samkelo")
        self.email = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_email"]').send_keys(
                "*****@*****.**")
        self.cnumber = self.driver.find_element(
            By.XPATH,
            '//*[@id="addCandidate_contactNo"]').send_keys("780479246")

        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.save_btn = Button(By.XPATH, '//*[@id="btnSave"]').click()

        time.sleep(3)

        return self
Пример #14
0
class LoginPage(BasePageObject):
    """Selenium Page Object Model: LoginPage."""

    # Page Elements
    username = InputText(By.NAME, "sUserName", wait=True)
    password = InputText(By.NAME, "sSysPass", wait=True)
    login_button = Button(By.NAME, "btnOk", wait=True)
    login_error_message = Text(By.ID, "errmsg")

    def login(self, username, passsword):
        """Submit login details to Web Admin login page.

        :param username: The username
        :param password: The password
        """
        self.set_element_value(self.username, username)
        self.set_element_value(self.password, passsword)
        self.login_button.click()

    def login_error(self):
        """Check for presence of login error text.

        :returns: True if error displayed, False otherwise
        """
        if self.login_error_message.is_visible():
            return True
        return False

    def error_message(self):
        """Return error message displayed on login page.

        :returns: Error message string
        """
        if self.login_error_message.is_visible():
            message = self.read_element_value(self.login_error_message)
        else:
            message = "No Error message returned - Login Failed"
        return message
Пример #15
0
 def ok_btn(self):
     self.OK_button = Button(By.XPATH, '//*[@id="confirmOkButton"]').click()
     time.sleep(5)
     return self
class SNMPpage(BasePageObject):
    """Selenium Page Object Model: SNMPpage."""

    # Page Elements
    snmp_agent_enable = Checkbox(By.NAME, "SNMPAgentEn")
    get_community = InputText(By.NAME, "SNMPGetCom")
    set_community = InputText(By.NAME, "SNMPSetCom")

    manager_host_v4_index_1 = InputText(By.NAME, "SNMPMngHostIP0")
    manager_host_v4_index_2 = InputText(By.NAME, "SNMPMngHostIP1")
    manager_host_v4_index_3 = InputText(By.NAME, "SNMPMngHostIP2")
    manager_host_v4_subnet_index_1 = Select(By.NAME, "SNMPMngHostMask0")
    manager_host_v4_subnet_index_2 = Select(By.NAME, "SNMPMngHostMask1")
    manager_host_v4_subnet_index_3 = Select(By.NAME, "SNMPMngHostMask2")

    manager_host_v6_index_1 = InputText(By.NAME, "SNMPMngHostIP_V60")
    manager_host_v6_index_2 = InputText(By.NAME, "SNMPMngHostIP_V61")
    manager_host_v6_index_3 = InputText(By.NAME, "SNMPMngHostIP_V62")
    manager_host_v6_prelen_index_1 = InputText(By.NAME, "SNMPMngHostPreLen_V60")
    manager_host_v6_prelen_index_2 = InputText(By.NAME, "SNMPMngHostPreLen_V61")
    manager_host_v6_prelen_index_3 = InputText(By.NAME, "SNMPMngHostPreLen_V62")

    trap_community = InputText(By.NAME, "SNMPTrapCom")
    trap_timeout = InputText(By.NAME, "SNMPTrapTimeOut")

    trap_host_v4_index_1 = InputText(By.NAME, "SNMPNotiHostIP0")
    trap_host_v4_index_2 = InputText(By.NAME, "SNMPNotiHostIP1")

    trap_host_v6_index_1 = InputText(By.NAME, "SNMPNotiHostIP_V60")
    trap_host_v6_index_2 = InputText(By.NAME, "SNMPNotiHostIP_V61")

    snmpv3_agent_enable = Checkbox(By.NAME, "SNMPV3En")
    snmpv3_usm_user = InputText(By.NAME, "SNMPUSMUser")
    snmpv3_auth_algo = Select(By.NAME, "SNMPAuthProto")
    snmpv3_auth_password = InputText(By.NAME, "SNMPAuthPwd")
    snmpv3_priv_algo = Select(By.NAME, "SNMPPrivProto")
    snmpv3_priv_password = InputText(By.NAME, "SNMPPrivPwd")

    ok_button = Button(By.NAME, "snmp_btnOk")

    def open_page(self):
        """Navigate menus to open SNMP configuration page."""
        menu = MenuNavigator(self.driver_wrapper)
        menu.open_sysmain_snmp()

    def check_reboot(self):
        """Check if reboot page is displayed, if so set flag to indicate a reboot is required.

        :returns: True if reboot page found. False otherwise
        """
        return MenuNavigator(self.driver_wrapper).is_reboot_system_displayed()

    def read_snmp_ipv4_settings(self):
        """Return the current SNMPIPv4 setting.

        :returns SNMPIPv4 object
        """
        self.open_page()
        return SNMPIPv4(
            enable_agent=self.read_element_value(self.snmp_agent_enable),
            get_community=self.read_element_value(self.get_community),
            set_community=self.read_element_value(self.set_community),
            manager_host_1=self.read_element_value(self.manager_host_v4_index_1),
            manager_host_subnet_1=self.read_element_value(
                self.manager_host_v4_subnet_index_1
            ),
            manager_host_2=self.read_element_value(self.manager_host_v4_index_2),
            manager_host_subnet_2=self.read_element_value(
                self.manager_host_v4_subnet_index_2
            ),
            manager_host_3=self.read_element_value(self.manager_host_v4_index_3),
            manager_host_subnet_3=self.read_element_value(
                self.manager_host_v4_subnet_index_3
            ),
        )

    def write_snmp_ipv4_settings(self, settings: SNMPIPv4):
        """Populate the SNMPIPv4 settings.

        :param settings: SNMPIPv4 object
        :returns reboot required (bool) - Indicating if settings change requires a reboot
        """
        self.open_page()
        self.set_element_value(self.snmp_agent_enable, settings.enable_agent)
        self.set_element_value(self.get_community, settings.get_community)
        self.set_element_value(self.set_community, settings.set_community)
        self.set_element_value(self.manager_host_v4_index_1, settings.manager_host_1)
        self.set_element_value(self.manager_host_v4_index_2, settings.manager_host_2)
        self.set_element_value(self.manager_host_v4_index_3, settings.manager_host_3)
        self.set_element_value(
            self.manager_host_v4_subnet_index_1, settings.manager_host_subnet_1
        )
        self.set_element_value(
            self.manager_host_v4_subnet_index_2, settings.manager_host_subnet_2
        )
        self.set_element_value(
            self.manager_host_v4_subnet_index_3, settings.manager_host_subnet_3
        )
        self.ok_button.click()
        return self.check_reboot()

    def read_snmp_ipv6_settings(self):
        """Return the current SNMPIPv6 settings.

        :returns SNMPIPv6 object
        """
        self.open_page()
        return SNMPIPv6(
            enable_agent=self.read_element_value(self.snmp_agent_enable),
            get_community=self.read_element_value(self.get_community),
            set_community=self.read_element_value(self.set_community),
            manager_host_1=self.read_element_value(self.manager_host_v6_index_1),
            manager_host_prelen_1=self.read_element_value(
                self.manager_host_v6_prelen_index_1
            ),
            manager_host_2=self.read_element_value(self.manager_host_v6_index_2),
            manager_host_prelen_2=self.read_element_value(
                self.manager_host_v6_prelen_index_2
            ),
            manager_host_3=self.read_element_value(self.manager_host_v6_index_3),
            manager_host_prelen_3=self.read_element_value(
                self.manager_host_v6_prelen_index_3
            ),
        )

    def write_snmp_ipv6_settings(self, settings: SNMPIPv6):
        """Populate the SNMPIPv6 settings.

        :param settings: SNMPIPv6 object
        :returns: reboot required (bool) - Indicating if settings change requires a reboot
        """
        self.open_page()
        self.set_element_value(self.snmp_agent_enable, settings.enable_agent)
        self.set_element_value(self.get_community, settings.get_community)
        self.set_element_value(self.set_community, settings.set_community)
        self.set_element_value(self.manager_host_v6_index_1, settings.manager_host_1)
        self.set_element_value(self.manager_host_v6_index_2, settings.manager_host_2)
        self.set_element_value(self.manager_host_v6_index_3, settings.manager_host_3)
        self.set_element_value(
            self.manager_host_v6_prelen_index_1, settings.manager_host_prelen_1
        )
        self.set_element_value(
            self.manager_host_v6_prelen_index_2, settings.manager_host_prelen_2
        )
        self.set_element_value(
            self.manager_host_v6_prelen_index_3, settings.manager_host_prelen_3
        )
        self.ok_button.click()
        return self.check_reboot()

    def read_snmp_ipv4_trap_setting(self):
        """Return the current SNMPIPv4 Trap settings.

        :returns: SNMPIPv4Trap object
        """
        self.open_page()
        return SNMPTrapIPv4(
            community=self.read_element_value(self.trap_community),
            timeout=self.read_element_value(self.trap_timeout),
            host_1=self.read_element_value(self.trap_host_v4_index_1),
            host_2=self.read_element_value(self.trap_host_v4_index_2),
        )

    def write_snmp_ipv4_trap_settings(self, settings: SNMPTrapIPv4):
        """Populate the SNMPIPv4 Trap settings.

        :param settings: SNMPIPv4Trap object
        :returns: reboot required (bool) - Indicating if settings change requires a reboot
        """
        self.open_page()
        self.set_element_value(self.trap_community, settings.community)
        self.set_element_value(self.trap_timeout, settings.timeout)
        self.set_element_value(self.trap_host_v4_index_1, settings.host_1)
        self.set_element_value(self.trap_host_v4_index_2, settings.host_2)
        self.ok_button.click()
        return self.check_reboot()

    def read_snmp_ipv6_trap_setting(self):
        """Return the current SNMPIPv6 Trap settings.

        :returns: SNMPIPv6Trap object
        """
        self.open_page()
        return SNMPTrapIPv6(
            community=self.read_element_value(self.trap_community),
            timeout=self.read_element_value(self.trap_timeout),
            host_1=self.read_element_value(self.trap_host_v6_index_1),
            host_2=self.read_element_value(self.trap_host_v6_index_2),
        )

    def write_snmp_ipv6_trap_settings(self, settings: SNMPTrapIPv6):
        """Populate the SNMPIPv6 Trap settings.

        :param settings: SNMPIPv6Trap object
        :returns: reboot required (bool) - Indicating if settings change requires a reboot
        """
        self.open_page()
        self.set_element_value(self.trap_community, settings.community)
        self.set_element_value(self.trap_timeout, settings.timeout)
        self.set_element_value(self.trap_host_v6_index_1, settings.host_1)
        self.set_element_value(self.trap_host_v6_index_2, settings.host_2)
        self.ok_button.click()
        return self.check_reboot()

    def read_snmp_v3_settings(self):
        """Return the current SNMPv3 settings.

        :returns: SNMPv3 object
        """
        self.open_page()
        return SNMPv3(
            enable_v3_agent=self.read_element_value(self.snmpv3_agent_enable),
            usm_user=self.read_element_value(self.snmpv3_usm_user),
            auth_algorithm=self.read_element_value(self.snmpv3_auth_algo),
            auth_password=self.read_element_value(self.snmpv3_auth_password),
            priv_algorithm=self.read_element_value(self.snmpv3_priv_algo),
            priv_password=self.read_element_value(self.snmpv3_priv_password),
        )

    def write_snmp_v3_settings(self, settings: SNMPv3):
        """Populate the SNMPv3 settings.

        :param settings: SNMPv3 object
        :returns: reboot required (bool) - Indicating if settings change requires a reboot
        """
        # Note: To enable SNMPv3 agent, you also have to enable the SNMPv1v2 agent.
        # Which also needs v1v2 community strings, manager hosts etc.
        self.open_page()
        if not self.set_element_value(
            self.snmpv3_agent_enable, settings.enable_v3_agent
        ):
            # Unable to enable V3 - Likely SNMP Agent for v1/v2 not enabled
            raise ValueError(
                f"Can't enable SNMPv3 Agent. Draytek requires v2 to be enabled and configured to use SNMPv3."
            )
        self.set_element_value(self.snmpv3_usm_user, settings.usm_user)
        self.set_element_value(self.snmpv3_auth_algo, settings.auth_algorithm)
        self.set_element_value(self.snmpv3_auth_password, settings.auth_password)
        self.set_element_value(self.snmpv3_priv_algo, settings.priv_algorithm)
        self.set_element_value(self.snmpv3_priv_password, settings.priv_password)
        self.ok_button.click()
        return self.check_reboot()
Пример #17
0
class IosLoginPageObject(BaseLoginPageObject):
    username = InputText(By.ID, 'username_id_ios')
    password = InputText(By.ID, 'password_id_ios')
    login_button = Button(By.ID, 'login_id_ios')
Пример #18
0
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()
Пример #19
0
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'txtUsername')
        self.password = InputText(By.NAME, 'txtPassword')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

        self.message = MessagePageObject()
Пример #20
0
class CandidatesPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'txtUsername')
        self.password = InputText(By.NAME, 'txtPassword')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/submit'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)

        return self

    def hover(self):
        self.element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewRecruitmentModule"]/b')

        self.hover = ActionChains(self.driver).move_to_element(
            self.element).perform()
        time.sleep(3)

        return self

    def click_candidates(self):
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewCandidates"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(3)

        return self

    def click_add(self):
        self.click_element = self.driver.find_element(By.XPATH,
                                                      '//*[@id="btnAdd"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(3)

        return self

    def fill_form(self):
        self.fname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_firstName"]').send_keys("Samkelo")
        self.mname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_middleName"]').send_keys("Sam")
        self.lname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_lastName"]').send_keys("Samkelo")
        self.email = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_email"]').send_keys(
                "*****@*****.**")
        self.cnumber = self.driver.find_element(
            By.XPATH,
            '//*[@id="addCandidate_contactNo"]').send_keys("780479246")

        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.save_btn = Button(By.XPATH, '//*[@id="btnSave"]').click()

        time.sleep(3)

        return self

    def back_btn(self):
        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.back_btn = Button(By.XPATH, '//*[@id="btnBack"]').click()

        time.sleep(3)

        return self

    def dlt_record(self):
        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="ohrmList_chkSelectAll"]')

        self.driver.implicitly_wait(15)
        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        self.driver.find_element(By.XPATH, '//*[@id="btnDelete"]').click()
        self.driver.implicitly_wait(10)
        #self.driver.find_element(By.XPATH, '//*[@id="dialogDeleteBtn"]').click()

        time.sleep(5)

        return self
Пример #21
0
    def shipping_page(self):
        self.shipping = Button(By.NAME, 'processCarrier').click()
        time.sleep(3)

        return self
 def add_btn(self):
     self.add = Button(By.ID, 'btnAdd').click()
     time.sleep(3)
Пример #23
0
class VacanciesPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'txtUsername')
        self.password = InputText(By.NAME, 'txtPassword')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/submit'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(5)
        self.login_button.click()
        time.sleep(10)

        return self
        #hover abover recruitment tab and make a cursor move to the vacancies tab
    def hover(self):
        self.element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewRecruitmentModule"]/b')

        self.hover = ActionChains(self.driver).move_to_element(
            self.element).perform()
        time.sleep(5)

        return self
        #clicks on vacancies
    def click_vacancies(self):
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewJobVacancy"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(5)

        return self

    def click_add(self):
        self.click_element = self.driver.find_element(By.XPATH,
                                                      '//*[@id="btnAdd"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(5)

        return self
Пример #24
0
class TabsPageObject(PageObject):
    """
    :Class represents web page elements for Login page.
    """
    def init_page_elements(self):
        """ Open page elements

        :returns: this page object instance
        """
        self.genre = Button(By.XPATH, '//*[@text="Songs by genre"]', wait=True)
        self.rock = Button(By.XPATH, '//*[@text="Rock songs"]', wait=True)
        self.song = Button(By.XPATH, '//*[@text="Silent Partner"]', wait=True)

    def SelectGenre(self):
        """ Select genre group

        :returns: this page object instance
        """
        try:
            self.logger.info(
                "\n=====================================Genre======================================"
            )
            self.logger.debug("Opening genres")
            self.logger.debug("Checking if the button is present : %s",
                              self.genre)
            self.logger.debug(
                "\n-----------------------------------------------------------------------------------"
            )

            self.genre.wait_until_visible()
            self.genre.click()
            time.sleep(2)
            return True
        except NoSuchElementException:
            self.logger.debug("error",
                              "Element {} does not exist".format(self.genre))
            return None

    def Rock(self):
        """ Select Rock music genre

        :returns: this page object instance
        """
        try:
            self.logger.info(
                "\n===============================Selecting Rock music from genre================================="
            )
            self.logger.debug("Choose a genre")
            self.logger.debug("Checking if the pageElement is present : %s",
                              self.rock)
            self.logger.debug(
                "\n-----------------------------------------------------------------------------------"
            )

            self.rock.wait_until_visible()
            self.rock.click()
            time.sleep(2)
            return True
        except NoSuchElementException:
            self.logger.debug("error",
                              "Element {} does not exist".format(self.rock))
            return None

    def SelectedSong(self):
        """ Select play selected song

        :returns: this page object instance
        """
        try:
            self.logger.info(
                "\n===============================Playing awakening================================="
            )
            self.logger.debug("Playing song.")
            self.logger.debug("Checking if the pageElement is present : %s",
                              self.song)
            self.logger.debug(
                "\n-----------------------------------------------------------------------------------"
            )

            self.song.wait_until_visible()
            self.song.click()
            time.sleep(10)
            return True
        except NoSuchElementException:
            self.logger.debug("error",
                              "Element {} does not exist".format(self.song))
            return None
Пример #25
0
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()
Пример #26
0
class AssignLeavePageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
        self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        self.logger.debug("Login with user '%s'", user['username'])
        time.sleep(5)
        self.username.text = user['username']
        self.password.text = user['password']
        self.login_button.click()
        time.sleep(5)

    def assign_leave(self):
        self.assign_leave_btn = self.driver.find_element(
            By.XPATH,
            '//*[@id="dashboard-quick-launch-panel-menu_holder"]/table/tbody/tr/td[1]/div/a'
        ).click()
        time.sleep(3)
        return self

    def leave_details(self):
        self.empl_name = self.driver.find_element(
            By.XPATH,
            '//*[@id="assignleave_txtEmployee_empName"]').send_keys('J')
        time.sleep(2)
        self.list = self.driver.find_element(
            By.XPATH, '/html/body/div[6]/ul/li[1]').click()
        time.sleep(2)
        self.leave_type = self.driver.find_element(
            By.XPATH,
            '//*[@id="assignleave_txtLeaveType"]/option[@value=1]').click()
        time.sleep(2)
        self.from_date = self.driver.find_element(
            By.XPATH, '//*[@id="assignleave_txtFromDate"]').click()
        time.sleep(2)
        self.start_date = self.driver.find_element(
            By.XPATH,
            '//*[@id="ui-datepicker-div"]/table/tbody/tr[4]/td[4]/a').click()
        time.sleep(2)
        self.to_date = self.driver.find_element(
            By.XPATH, '//*[@id="assignleave_txtToDate"]').click()
        time.sleep(5)
        self.end_date = self.driver.find_element(
            By.XPATH,
            '//*[@id="ui-datepicker-div"]/table/tbody/tr[5]/td[5]/a').click()
        time.sleep(5)
        self.button = Button(By.XPATH, '//*[@id="assignBtn"]').click()
        time.sleep(5)

    def ok_btn(self):
        self.OK_button = Button(By.XPATH, '//*[@id="confirmOkButton"]').click()
        time.sleep(5)
        return self
Пример #27
0
class ManagementPage(BasePageObject):
    """Selenium Page Object Model: ManagementPage."""

    # Page Elements
    ipv4_management_setup_tab = Link(By.ID, "tab1")
    ipv6_management_setup_tab = Link(By.ID, "tab2")
    lan_access_setup_tab = Link(By.ID, "tab3")
    ok_button = Button(By.CLASS_NAME, "btnw")

    # TAB: IPv4 Management Setup
    router_name = InputText(By.NAME, "sRouterName")
    disable_auto_logout = Checkbox(By.NAME, "sDeflogoff")
    enable_validation_code = Checkbox(By.NAME, "sValidatedCode")

    # Internet Access Control
    enable_internet_access = Checkbox(By.NAME, "sRMC")
    domain_name_allowed = InputText(By.NAME, "sSysAllDomain")
    ftp = Checkbox(By.NAME, "sRMCFtp")
    http = Checkbox(By.NAME, "sRMCHttp")
    enforce_https_access = Checkbox(By.NAME, "iRMCHsfrc")
    https = Checkbox(By.NAME, "sRMCHttps")
    telnet = Checkbox(By.NAME, "sRMCTelnet")
    tr069 = Checkbox(By.NAME, "sRMCTr069")
    ssh = Checkbox(By.NAME, "sRMCSsh")
    snmp = Checkbox(By.NAME, "sRMCSnmp")
    disable_ping_from_internet = Checkbox(By.NAME, "sWPing")

    # Access List from the Internet
    access_index_1 = InputText(By.NAME, "index1")
    access_index_2 = InputText(By.NAME, "index2")
    access_index_3 = InputText(By.NAME, "index3")
    access_index_4 = InputText(By.NAME, "index4")
    access_index_5 = InputText(By.NAME, "index5")
    access_index_6 = InputText(By.NAME, "index6")
    access_index_7 = InputText(By.NAME, "index7")
    access_index_8 = InputText(By.NAME, "index8")
    access_index_9 = InputText(By.NAME, "index9")
    access_index_10 = InputText(By.NAME, "index10")

    # Management Port Setup
    user_defined_ports_radio = InputRadio(
        By.XPATH,
        "//input[@name='ConfigPort' and @type='radio' and @value='UserDefine']",
    )
    default_ports_radio = InputRadio(
        By.XPATH,
        "//input[@name='ConfigPort' and @type='radio' and @value='Default']")
    telnet_port = InputText(By.NAME, "TelnetPort")
    http_port = InputText(By.NAME, "HttpPort")
    https_port = InputText(By.NAME, "HttpsPort")
    ftp_port = InputText(By.NAME, "txtFtpPort")
    tr069_port = InputText(By.NAME, "txtTr069Port")
    ssh_port = InputText(By.NAME, "txtSshPort")

    # Bruce Force Protection
    bf_enable = Checkbox(By.NAME, "iBrEn")
    bf_ftp = Checkbox(By.NAME, "iBrFtp")
    bf_http = Checkbox(By.NAME, "iBrHttp")
    bf_https = Checkbox(By.NAME, "iBrHttps")
    bf_telnet = Checkbox(By.NAME, "iBrTelnet")
    bf_tr069 = Checkbox(By.NAME, "iBrTr069")
    bf_ssh = Checkbox(By.NAME, "iBrSsh")
    bf_max_login_failures = InputText(By.NAME, "iLoginFailures")
    bf_penality_period = InputText(By.NAME, "iPenaltyPeriod")

    # TLS/SSL Encryption Setup
    enc_tls12 = Checkbox(By.NAME, "enTLSv1_2")
    enc_tls11 = Checkbox(By.NAME, "enTLSv1_1")
    enc_tls10 = Checkbox(By.NAME, "enTLSv1")
    enc_ssl30 = Checkbox(By.NAME, "enSSLv3")

    # CVM Access Control
    cvm_port_enable = Checkbox(By.NAME, "CvmHttpEnb")
    cvm_port = InputText(By.NAME, "CvmHttpPort")
    cvm_ssl_port_enable = Checkbox(By.NAME, "CvmHttpsEnb")
    cvm_ssl_port = InputText(By.NAME, "CvmHttpsPort")

    # AP Management
    ap_management = Checkbox(By.NAME, "ApmEn")

    # Device Management
    device_management = Checkbox(By.NAME, "chkDevMng")
    device_management_respond_external = Checkbox(By.NAME, "NoRsp2ExDev")

    # TAB: IPv6 Management Setup
    ipv6_enable_internet_access = Checkbox(By.NAME, "sIp6RMC")
    ipv6_http = Checkbox(By.NAME, "sIp6Http")
    ipv6_https = Checkbox(By.NAME, "sIp6Https")
    ipv6_telnet = Checkbox(By.NAME, "sIp6Telnt")
    ipv6_ssh = Checkbox(By.NAME, "sIp6Ssh")
    ipv6_snmp = Checkbox(By.NAME, "sIp6Snmp")
    ipv6_disable_ping_from_internet = Checkbox(By.NAME, "sIp6Ping")

    ipv6_access_list_index_1 = InputText(By.NAME, "v6index1")
    ipv6_access_list_index_2 = InputText(By.NAME, "v6index2")
    ipv6_access_list_index_3 = InputText(By.NAME, "v6index3")
    ipv6_access_list_index_4 = InputText(By.NAME, "v6index4")
    ipv6_access_list_index_5 = InputText(By.NAME, "v6index5")
    ipv6_access_list_index_6 = InputText(By.NAME, "v6index6")
    ipv6_access_list_index_7 = InputText(By.NAME, "v6index7")
    ipv6_access_list_index_8 = InputText(By.NAME, "v6index8")
    ipv6_access_list_index_9 = InputText(By.NAME, "v6index9")
    ipv6_access_list_index_10 = InputText(By.NAME, "v6index10")

    # TAB: LAN Access Setup
    allow_management_from_lan = Checkbox(By.NAME, "sMngtfrmLanEn1")
    lan_ftp = Checkbox(By.NAME, "iMngtlanftp1")
    lan_http = Checkbox(By.NAME, "iMngtlanHttp1")
    lan_enforce_https_access = Checkbox(By.NAME, "iMngtHsfrc1")
    lan_https = Checkbox(By.NAME, "iMngtlanHttps1")
    lan_telnet = Checkbox(By.NAME, "iMngtlanTelnet1")
    lan_tr069 = Checkbox(By.NAME, "iMngtlanTr0691")
    lan_ssh = Checkbox(By.NAME, "iMngtlanSsh1")
    subnet_lan_1 = Checkbox(By.NAME, "iMngtlanacc0")
    subnet_lan_1_use_index = Checkbox(By.NAME, "iMngObjen0")
    subnet_lan_1_index = InputText(By.NAME, "iMngObjidx0")
    subnet_lan_2 = Checkbox(By.NAME, "iMngtlanacc1")
    subnet_lan_2_use_index = Checkbox(By.NAME, "iMngObjen1")
    subnet_lan_2_index = InputText(By.NAME, "iMngObjidx1")
    subnet_lan_3 = Checkbox(By.NAME, "iMngtlanacc2")
    subnet_lan_3_use_index = Checkbox(By.NAME, "iMngObjen2")
    subnet_lan_3_index = InputText(By.NAME, "iMngObjidx2")
    subnet_lan_4 = Checkbox(By.NAME, "iMngtlanacc3")
    subnet_lan_4_use_index = Checkbox(By.NAME, "iMngObjen3")
    subnet_lan_4_index = InputText(By.NAME, "iMngObjidx3")
    subnet_lan_5 = Checkbox(By.NAME, "iMngtlanacc4")
    subnet_lan_5_use_index = Checkbox(By.NAME, "iMngObjen4")
    subnet_lan_5_index = InputText(By.NAME, "iMngObjidx4")
    subnet_lan_6 = Checkbox(By.NAME, "iMngtlanacc5")
    subnet_lan_6_use_index = Checkbox(By.NAME, "iMngObjen5")
    subnet_lan_6_index = InputText(By.NAME, "iMngObjidx5")
    subnet_lan_dmz = Checkbox(By.NAME, "iMngObjendmz")
    subnet_lan_ip_routed = Checkbox(By.NAME, "iMngtlanSub1")
    subnet_lan_ip_routed_use_index = Checkbox(By.NAME, "iMngObjensub")
    subnet_lan_ip_routed_index = InputText(By.NAME, "iMngObjidxsub")

    def open_page(self, tab=None):
        """Navigate menus to open SNMP configuration page."""
        menu = MenuNavigator(self.driver_wrapper)
        menu.open_sysmain_management(tab)

    def check_reboot(self):
        """Check if reboot page is displayed, if so set flag to indicate a reboot is required.

        :returns: True if reboot page found. False otherwise
        """
        return MenuNavigator(self.driver_wrapper).is_reboot_system_displayed()

    def read_management_settings(self):
        """Return the current Management settings.

        :returns: Management object

        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return Management(
            router_name=self.read_element_value(self.router_name),
            disable_auto_logout=self.read_element_value(
                self.disable_auto_logout),
            enable_validation_code=self.read_element_value(
                self.enable_validation_code),
        )

    def write_management_settings(self, settings: Management):
        """Populate the Management setting.

        :param settings: Management object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.router_name, settings.router_name)
        self.set_element_value(self.disable_auto_logout,
                               settings.disable_auto_logout)
        self.set_element_value(self.enable_validation_code,
                               settings.enable_validation_code)
        self.ok_button.click()
        return self.check_reboot()

    def read_internet_access_control_settings(self):
        """Return the current InternetAccessControl settings.

        :returns: InternetAccessControl object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return InternetAccessControl(
            internet_management=self.read_element_value(
                self.enable_internet_access),
            domain_name_allowed=self.read_element_value(
                self.domain_name_allowed),
            ftp_server=self.read_element_value(self.ftp),
            http_server=self.read_element_value(self.http),
            enforce_https_access=self.read_element_value(
                self.enforce_https_access),
            https_server=self.read_element_value(self.https),
            telnet_server=self.read_element_value(self.telnet),
            tr069_server=self.read_element_value(self.tr069),
            ssh_server=self.read_element_value(self.ssh),
            snmp_server=self.read_element_value(self.snmp),
            disable_ping_from_internet=self.read_element_value(
                self.disable_ping_from_internet),
        )

    def write_internet_access_control_settings(
            self, settings: InternetAccessControl):
        """Populate the InternetAccessControl setting.

        :param settings: InternetAccessControl object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.enable_internet_access,
                               settings.internet_management)
        self.set_element_value(self.domain_name_allowed,
                               settings.domain_name_allowed)
        self.set_element_value(self.ftp, settings.ftp_server)
        self.set_element_value(self.http, settings.http_server)
        self.set_element_value(self.enforce_https_access,
                               settings.enforce_https_access)
        self.set_element_value(self.https, settings.https_server)
        self.set_element_value(self.telnet, settings.telnet_server)
        self.set_element_value(self.tr069, settings.tr069_server)
        self.set_element_value(self.ssh, settings.ssh_server)
        self.set_element_value(self.snmp, settings.snmp_server)
        self.set_element_value(self.disable_ping_from_internet,
                               settings.disable_ping_from_internet)
        self.ok_button.click()
        return self.check_reboot()

    def read_access_list_settings(self):
        """Return the current AccessList settings.

        :returns: AccessList object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return AccessList(
            list_1_ip_object_index=self.read_element_value(
                self.access_index_1),
            list_2_ip_object_index=self.read_element_value(
                self.access_index_2),
            list_3_ip_object_index=self.read_element_value(
                self.access_index_3),
            list_4_ip_object_index=self.read_element_value(
                self.access_index_4),
            list_5_ip_object_index=self.read_element_value(
                self.access_index_5),
            list_6_ip_object_index=self.read_element_value(
                self.access_index_6),
            list_7_ip_object_index=self.read_element_value(
                self.access_index_7),
            list_8_ip_object_index=self.read_element_value(
                self.access_index_8),
            list_9_ip_object_index=self.read_element_value(
                self.access_index_9),
            list_10_ip_object_index=self.read_element_value(
                self.access_index_10),
        )

    def write_access_list_settings(self, settings: AccessList):
        """Populate the AccessList setting.

        :param settings: AccessList object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.access_index_1,
                               settings.list_1_ip_object_index)
        self.set_element_value(self.access_index_2,
                               settings.list_2_ip_object_index)
        self.set_element_value(self.access_index_3,
                               settings.list_3_ip_object_index)
        self.set_element_value(self.access_index_4,
                               settings.list_4_ip_object_index)
        self.set_element_value(self.access_index_5,
                               settings.list_5_ip_object_index)
        self.set_element_value(self.access_index_6,
                               settings.list_6_ip_object_index)
        self.set_element_value(self.access_index_7,
                               settings.list_7_ip_object_index)
        self.set_element_value(self.access_index_8,
                               settings.list_8_ip_object_index)
        self.set_element_value(self.access_index_9,
                               settings.list_9_ip_object_index)
        self.set_element_value(self.access_index_10,
                               settings.list_10_ip_object_index)
        self.ok_button.click()
        return self.check_reboot()

    def read_management_port_settings(self):
        """Return the current ManagementPort settings.

        :returns: ManagementPort object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return ManagementPort(
            user_defined_ports=self.read_element_value(
                self.user_defined_ports_radio),
            telnet_port=self.read_element_value(self.telnet_port),
            http_port=self.read_element_value(self.http_port),
            https_port=self.read_element_value(self.https_port),
            ftp_port=self.read_element_value(self.ftp_port),
            tr069_port=self.read_element_value(self.tr069_port),
            ssh_port=self.read_element_value(self.ssh_port),
        )

    def write_management_port_settings(self, settings: ManagementPort):
        """Populate the ManagementPort setting.

        :param settings: ManagementPort object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        if settings.user_defined_ports:
            self.set_element_value(self.user_defined_ports_radio,
                                   settings.user_defined_ports)
            self.set_element_value(self.telnet_port, settings.telnet_port)
            self.set_element_value(self.http_port, settings.http_port)
            self.set_element_value(self.https_port, settings.https_port)
            self.set_element_value(self.ftp_port, settings.ftp_port)
            self.set_element_value(self.tr069_port, settings.tr069_port)
            self.set_element_value(self.ssh_port, settings.ssh_port)
        else:
            self.set_element_value(self.default_ports_radio, True)
        self.ok_button.click()
        return self.check_reboot()

    def read_brute_force_protection_settings(self):
        """Return the current BruteForceProtection settings.

        :returns: BruteForceProtection object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return BruteForceProtection(
            enable=self.read_element_value(self.bf_enable),
            ftp_server=self.read_element_value(self.bf_ftp),
            http_server=self.read_element_value(self.bf_http),
            https_server=self.read_element_value(self.bf_https),
            telnet_server=self.read_element_value(self.bf_telnet),
            tr069_server=self.read_element_value(self.bf_tr069),
            ssh_server=self.read_element_value(self.bf_ssh),
            max_login_failures=self.read_element_value(
                self.bf_max_login_failures),
            penalty_period=self.read_element_value(self.bf_penality_period),
        )

    def write_brute_force_protection_settings(self,
                                              settings: BruteForceProtection):
        """Populate the BruteForceProtection setting.

        :param settings: BruteForceProtection object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.bf_enable, settings.enable)
        self.set_element_value(self.bf_ftp, settings.ftp_server)
        self.set_element_value(self.bf_http, settings.http_server)
        self.set_element_value(self.bf_https, settings.https_server)
        self.set_element_value(self.bf_telnet, settings.telnet_server)
        self.set_element_value(self.bf_tr069, settings.tr069_server)
        self.set_element_value(self.bf_ssh, settings.ssh_server)
        self.set_element_value(self.bf_max_login_failures,
                               settings.max_login_failures)
        self.set_element_value(self.bf_penality_period,
                               settings.penalty_period)
        self.ok_button.click()
        return self.check_reboot()

    def read_encryption_settings(self):
        """Return the current Encryption settings.

        :returns: Encryption object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return Encryption(
            tls_1_2=self.read_element_value(self.enc_tls12),
            tls_1_1=self.read_element_value(self.enc_tls11),
            tls_1_0=self.read_element_value(self.enc_tls10),
            ssl_3_0=self.read_element_value(self.enc_ssl30),
        )

    def write_encryption_settings(self, settings: Encryption):
        """Populate the Encryption setting.

        :param settings: Encryption object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.enc_tls12, settings.tls_1_2)
        self.set_element_value(self.enc_tls11, settings.tls_1_1)
        self.set_element_value(self.enc_tls10, settings.tls_1_0)
        self.set_element_value(self.enc_ssl30, settings.ssl_3_0)
        self.ok_button.click()
        return self.check_reboot()

    def read_cvm_access_control_settings(self):
        """Return the current CVM_AccessControl settings.

        :returns: CVM_AccessControl object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return CVM_AccessControl(
            enable=self.read_element_value(self.cvm_port_enable),
            ssl_enable=self.read_element_value(self.cvm_ssl_port_enable),
            port=self.read_element_value(self.cvm_port),
            ssl_port=self.read_element_value(self.cvm_ssl_port),
        )

    def write_cvm_access_control_settings(self, settings: CVM_AccessControl):
        """Populate the CVM_AccessControl setting.

        :param settings: CVM_AccessControl object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.cvm_port_enable, settings.enable)
        self.set_element_value(self.cvm_ssl_port_enable, settings.ssl_enable)
        self.set_element_value(self.cvm_port, settings.port)
        self.set_element_value(self.cvm_ssl_port, settings.ssl_port)
        self.ok_button.click()
        return self.check_reboot()

    def read_ap_management_settings(self):
        """Return the current AP_Management settings.

        :returns: AP_Management object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return AP_Management(enable=self.read_element_value(
            self.ap_management), )

    def write_ap_management_settings(self, settings: AP_Management):
        """Populate the AP_Management setting.

        :param settings: AP_Management object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.ap_management, settings.enable)
        self.ok_button.click()
        return self.check_reboot()

    def read_device_management_settings(self):
        """Return the current DeviceManagement settings.

        :returns: DeviceManagement object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        return DeviceManagement(
            enable=self.read_element_value(self.device_management),
            respond_to_external_device=self.read_element_value(
                self.device_management_respond_external),
        )

    def write_device_management_settings(self, settings: DeviceManagement):
        """Populate the DeviceManagement setting.

        :param settings: DeviceManagement object
        """
        self.open_page(tab=self.ipv4_management_setup_tab)
        self.set_element_value(self.device_management, settings.enable)
        self.set_element_value(self.device_management_respond_external,
                               settings.respond_to_external_device)
        self.ok_button.click()
        return self.check_reboot()

    def read_ipv6_management_settings(self):
        """Return the currrent IPv6 Management settings.

        :returns IPv6Management object
        """
        self.open_page(tab=self.ipv6_management_setup_tab)
        return IPv6Management(
            internet_management=self.read_element_value(
                self.ipv6_enable_internet_access),
            telnet_server=self.read_element_value(self.ipv6_telnet),
            http_server=self.read_element_value(self.ipv6_http),
            https_server=self.read_element_value(self.ipv6_https),
            ssh_server=self.read_element_value(self.ipv6_ssh),
            snmp_server=self.read_element_value(self.ipv6_snmp),
            disable_ping_from_internet=self.read_element_value(
                self.ipv6_disable_ping_from_internet),
            access_index_1=self.read_element_value(
                self.ipv6_access_list_index_1),
            access_index_2=self.read_element_value(
                self.ipv6_access_list_index_2),
            access_index_3=self.read_element_value(
                self.ipv6_access_list_index_3),
            access_index_4=self.read_element_value(
                self.ipv6_access_list_index_4),
            access_index_5=self.read_element_value(
                self.ipv6_access_list_index_5),
            access_index_6=self.read_element_value(
                self.ipv6_access_list_index_6),
            access_index_7=self.read_element_value(
                self.ipv6_access_list_index_7),
            access_index_8=self.read_element_value(
                self.ipv6_access_list_index_8),
            access_index_9=self.read_element_value(
                self.ipv6_access_list_index_9),
            access_index_10=self.read_element_value(
                self.ipv6_access_list_index_10),
        )

    def write_ipv6_management_settings(self, settings: IPv6Management):
        """Populate the IPv6Management setting.

        :param settings: IPv6Management object
        """
        self.open_page(tab=self.ipv6_management_setup_tab)
        self.set_element_value(self.ipv6_enable_internet_access,
                               settings.internet_management)
        self.set_element_value(self.ipv6_telnet, settings.telnet_server)
        self.set_element_value(self.ipv6_http, settings.http_server)
        self.set_element_value(self.ipv6_https, settings.https_server)
        self.set_element_value(self.ipv6_ssh, settings.ssh_server)
        self.set_element_value(self.ipv6_snmp, settings.snmp_server)
        self.set_element_value(self.ipv6_disable_ping_from_internet,
                               settings.disable_ping_from_internet)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_1)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_2)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_3)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_4)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_5)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_6)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_7)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_8)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_9)
        self.set_element_value(self.ipv6_access_list_index_1,
                               settings.access_index_10)

        self.ok_button.click()
        return self.check_reboot()

    def read_lan_access_settings(self):
        """Return the current LAN_Access settings.

        :returns: LAN_Access object
        """
        self.open_page(tab=self.lan_access_setup_tab)
        return LAN_Access(
            enable=self.read_element_value(self.allow_management_from_lan),
            ftp_server=self.read_element_value(self.lan_ftp),
            http_server=self.read_element_value(self.lan_http),
            enforce_https_access=self.read_element_value(
                self.lan_enforce_https_access),
            https_server=self.read_element_value(self.lan_https),
            telnet_server=self.read_element_value(self.lan_telnet),
            tr069_server=self.read_element_value(self.lan_tr069),
            ssh_server=self.read_element_value(self.lan_ssh),
            lan_1_access=self.read_element_value(self.subnet_lan_1),
            lan_1_use_index=self.read_element_value(
                self.subnet_lan_1_use_index),
            lan_1_index=self.read_element_value(self.subnet_lan_1_index),
            lan_2_access=self.read_element_value(self.subnet_lan_2),
            lan_2_use_index=self.read_element_value(
                self.subnet_lan_2_use_index),
            lan_2_index=self.read_element_value(self.subnet_lan_2_index),
            lan_3_access=self.read_element_value(self.subnet_lan_3),
            lan_3_use_index=self.read_element_value(
                self.subnet_lan_3_use_index),
            lan_3_index=self.read_element_value(self.subnet_lan_3_index),
            lan_4_access=self.read_element_value(self.subnet_lan_4),
            lan_4_use_index=self.read_element_value(
                self.subnet_lan_4_use_index),
            lan_4_index=self.read_element_value(self.subnet_lan_4_index),
            lan_5_access=self.read_element_value(self.subnet_lan_5),
            lan_5_use_index=self.read_element_value(
                self.subnet_lan_5_use_index),
            lan_5_index=self.read_element_value(self.subnet_lan_5_index),
            lan_6_access=self.read_element_value(self.subnet_lan_6),
            lan_6_use_index=self.read_element_value(
                self.subnet_lan_6_use_index),
            lan_6_index=self.read_element_value(self.subnet_lan_6_index),
            dmz_access=self.read_element_value(self.subnet_lan_dmz),
            lan_ip_routed_access=self.read_element_value(
                self.subnet_lan_ip_routed),
            lan_ip_routed_use_index=self.read_element_value(
                self.subnet_lan_ip_routed_use_index),
            lan_ip_routed_index=self.read_element_value(
                self.subnet_lan_ip_routed_index),
        )

    def write_lan_access_settings(self, settings: LAN_Access):
        """Populate the LAN_Access setting.

        :param settings: LAN_Access object
        """
        self.open_page(tab=self.lan_access_setup_tab)
        self.set_element_value(self.allow_management_from_lan, settings.enable)
        self.set_element_value(self.lan_ftp, settings.ftp_server)
        self.set_element_value(self.lan_http, settings.http_server)
        self.set_element_value(self.lan_enforce_https_access,
                               settings.enforce_https_access)
        self.set_element_value(self.lan_https, settings.https_server)
        self.set_element_value(self.lan_telnet, settings.telnet_server)
        self.set_element_value(self.lan_tr069, settings.tr069_server)
        self.set_element_value(self.lan_ssh, settings.ssh_server)
        self.set_element_value(self.subnet_lan_1, settings.lan_1_access)
        self.set_element_value(self.subnet_lan_1_use_index,
                               settings.lan_1_use_index)
        self.set_element_value(self.subnet_lan_1_index, settings.lan_1_index)
        self.set_element_value(self.subnet_lan_2, settings.lan_2_access)
        self.set_element_value(self.subnet_lan_2_use_index,
                               settings.lan_2_use_index)
        self.set_element_value(self.subnet_lan_2_index, settings.lan_2_index)
        self.set_element_value(self.subnet_lan_3, settings.lan_3_access)
        self.set_element_value(self.subnet_lan_3_use_index,
                               settings.lan_3_use_index)
        self.set_element_value(self.subnet_lan_3_index, settings.lan_3_index)
        self.set_element_value(self.subnet_lan_4, settings.lan_4_access)
        self.set_element_value(self.subnet_lan_4_use_index,
                               settings.lan_4_use_index)
        self.set_element_value(self.subnet_lan_4_index, settings.lan_4_index)
        self.set_element_value(self.subnet_lan_5, settings.lan_5_access)
        self.set_element_value(self.subnet_lan_5_use_index,
                               settings.lan_5_use_index)
        self.set_element_value(self.subnet_lan_5_index, settings.lan_5_index)
        self.set_element_value(self.subnet_lan_6, settings.lan_6_access)
        self.set_element_value(self.subnet_lan_6_use_index,
                               settings.lan_6_use_index)
        self.set_element_value(self.subnet_lan_6_index, settings.lan_6_index)
        self.set_element_value(self.subnet_lan_dmz, settings.dmz_access)
        self.set_element_value(self.subnet_lan_ip_routed,
                               settings.lan_ip_routed_access)
        self.set_element_value(self.subnet_lan_ip_routed_use_index,
                               settings.lan_ip_routed_use_index)
        self.set_element_value(self.subnet_lan_ip_routed_index,
                               settings.lan_ip_routed_index)
        self.ok_button.click()
        return self.check_reboot()
Пример #28
0
class Buying_ItemPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)

    # return SecureAreaPageObject(self.driver_wrapper)

    #hover over the women tab
    def hover(self):
        self.element = self.driver.find_element(
            By.XPATH, '//*[@id="block_top_menu"]/ul/li[1]/a')

        self.hover = ActionChains(self.driver).move_to_element(
            self.element).perform()
        time.sleep(3)

        return self

        #hover over women tab and move cursor to blouses and click
    def click_tops(self):
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="block_top_menu"]/ul/li[1]/ul/li[1]/ul/li[2]/a')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(3)

        return self

    def addItem(self):
        #scroll to bottom
        self.driver.execute_script(
            "window.scrollTo(0, -170, document.body.scrollHeight);")

        #Hover to blouse and click add to cart button
        self.item = self.driver.find_element(
            By.XPATH, '//*[@id="center_column"]/ul/li/div/div[2]/h5/a')

        self.button = ActionChains(self.driver).move_to_element(
            self.item).perform()

        self.add_to_cart = self.driver.find_element(
            By.XPATH,
            '//*[@id="center_column"]/ul/li/div/div[2]/div[2]/a[1]').click()
        time.sleep(3)

        return self

        #click Proceed to checkout button to shopping-cart summary page
    def go_to_checkout(self):
        self.checkout = self.driver.find_element(
            By.XPATH, '//*[@id="layer_cart"]/div[1]/div[2]/div[4]/a').click()
        time.sleep(3)

        return self

        #click proceed button to addresses page
    def shopping_summary(self):
        self.summary = self.driver.find_element(
            By.XPATH, '//*[@id="center_column"]/p[2]/a[1]').click()
        time.sleep(3)

        return self

        #click proceed button to shipping page
    def address_verification(self):
        self.address = Button(By.NAME, 'processAddress').click()
        time.sleep(3)

        return self

        #click the agree on terms checkbox buttton
    def agree_on_terms(self):
        self.agree_terms = self.driver.find_element(By.XPATH,
                                                    '//*[@id="cgv"]').click()
        time.sleep(3)

        return self

        #click Proceed to checkout button to payment method page
    def shipping_page(self):
        self.shipping = Button(By.NAME, 'processCarrier').click()
        time.sleep(3)

        return self

        #Click payment method button
    def payment_method(self):
        self.payment_type = self.driver.find_element(
            By.XPATH, '//*[@id="HOOK_PAYMENT"]/div[2]/div/p/a').click()
        time.sleep(3)

        return self

        #Click confirm order button
    def confirm_order(self):
        self.confirm_order = self.driver.find_element(
            By.XPATH, '//*[@id="cart_navigation"]/button').click()
        time.sleep(10)

        self.confirm_order = self.driver.find_element(
            By.XPATH, '//*[@id="header"]/div[2]/div/div/nav/div[2]/a').click()
        time.sleep(5)

        return self
 def init_page_elements(self):
     self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
     self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
     self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')
Пример #30
0
class SearchPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.ID, 'email')
        self.password = InputText(By.ID, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.logger.debug("\nAtempting to open the page")
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))

        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        try:
            self.logger.debug("Login with user '%s'", user['username'])
            self.username.text = user['username']
            self.password.text = user['password']
            self.logger.debug("\nAtempting to click login button")
            self.login_button.click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
            return None

    def search(self):
        try:
            self.search_item = self.driver.find_element(
                By.XPATH, '//*[@id="search_query_top"]').send_keys('t-shirt')
            self.search_btn = self.driver.find_element(
                By.XPATH, '//*[@id="searchbox"]/button').click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
            return None

    def add_item(self):
        try:
            self.driver.execute_script(
                "window.scrollTo(0, 200, document.body.scrollHeight)")
            self.item = self.driver.find_element(
                By.XPATH, '//*[@id="center_column"]/ul/li/div/div[2]/h5/a')
            self.hover = ActionChains(self.driver).move_to_element(
                self.item).perform()
            self.add_btn = self.driver.find_element(
                By.XPATH,
                '//*[@id="center_column"]/ul/li/div/div[2]/div[2]/a[2]').click(
                )
            self.add_to_cart = self.driver.find_element(
                By.XPATH, '//*[@id="add_to_cart"]/button').click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
Пример #31
0
class AndroidLoginPageObject(BaseLoginPageObject):
    username = InputText(By.ID, 'username_id_android')
    password = InputText(By.ID, 'password_id_android')
    login_button = Button(By.ID, 'login_id_android')
Пример #32
0
    def address_verification(self):
        self.address = Button(By.NAME, 'processAddress').click()
        time.sleep(3)

        return self