Exemple #1
0
def login(driver, url, username, password):
    login_page = LoginPage(driver)
    login_page.open_url(url)
    login_page.set_browser_max()
    login_page.input_username(username)
    login_page.input_password(password)
    login_page.click_login()
    #操作
    def get_companyname(self):  #获取公司名称
        value = self.get_text(self.companyname_shwbox)
        return value

    def go_myzone(self):  #进入我的地盘
        self.cilck(self.go_myzone())

    def goto_product(self):  #进入产品模块
        self.cilck(self.go_myzone())

    def get_username(self):  #获取用户名
        value = self.get_text(self.username_showspan)
        return value


if __name__ == '__main__':
    webdriver_path = os.path.join(os.path.dirname(__file__), '..', 'webdriver',
                                  'chromedriver.exe')
    driver = webdriver.Chrome(executable_path=webdriver_path)
    login_page = LoginPage(driver)
    login_page.open_url(
        'http://47.107.178.45/zentao/www/index.php?m=user&f=login')
    login_page.set_browser_max()
    login_page.input_username('test01')
    login_page.input_password('newdream123')
    login_page.click_login()
    companyname = MainPage(driver).get_companyname()
    username = MainPage(driver).get_username()
    print(companyname)
    print(username)