
from page_class.base_page import BasePage
from selenium.webdriver.common.by import By


class PageLogin(BasePage):
    # 账号
    _account_locator = (By.ID, 'input1')
    # 密码
    _pass_locator = (By.ID, 'input2')
    # 验证码输入
    _verify_code_locator = (By.ID, 'photoCode')
    # 验证码图片
    _verify_image_locator = (By.ID, 'canvas')
    # 登录按钮
    _login_button_locator = (By.ID, 'loginBtn')
    # 输入信息后，登录结果,主要针对错误输入
    _login_result_locator = (By.XPATH, '//div[@id="simplealert"]/div[@class = "msg"]')

    '''获取账号'''

    def get_account(self):
        return self.get_element_wait_presence(self._account_locator)

    '''获取密码'''

    def get_password(self):
        return self.get_element_wait_presence(self._pass_locator)

    '''获取验证码'''

    def get_verify_code(self):
        return self.get_element_wait_presence(self._verify_code_locator)

    '''获取验证码图片元素'''

    def get_verify_image(self):
        return self.get_element_wait_presence(self._verify_image_locator)

    '''获取登录按钮元素'''

    def get_login_button(self):
        return self.get_element_wait_presence(self._login_button_locator)

    '''输入用户密码验证码后，登录结果提示'''

    def get_login_result(self):
        return self.get_element_wait_presence(self._login_result_locator)
