def manage_driver(): """管理浏览器""" # 步骤一:初始化浏览器 driver = webdriver.Chrome() # 浏览器最大化 driver.maximize_window() # 步骤二:初始化页面: # 申明login_page相关的信息 login_page = LoginPage(driver) user_page=UserPage(driver) # 步骤三:通过yield保存manage_browser返回过来的参数 yield driver, login_page,user_page # 步骤四:关闭浏览器 driver.quit()
def invest_setup(): driver = create_dirver() driver.maximize_window() driver.implicitly_wait(15) driver.get(conf.get('env', 'base_url') + conf.get('env', 'url_path')) login_page = LoginPage(driver) # 登录 login_page.login(conf.get("test_data", "phone"), conf.get("test_data", "pwd")) # 创建首页对象 index_page = IndexPage(driver) # 点击抢投标 index_page.click_invest_loan() # 进入投资页面 invest_page = InvestPage(driver) user_page = UserPage(driver) yield invest_page, user_page driver.quit()
def setUp(self): """登录""" self.driver = webdriver.Chrome() self.driver.get(self.url) self.driver.maximize_window() # 设置隐式等待 self.driver.implicitly_wait(30) # # 初始化要用到的页面 self.login_page = LoginPage(self.driver) self.user_page = UserPage(self.driver) self.merchant_manage_page = MerchantPage(self.driver) # 登录 # 步骤一:输入手机号和密码,登录 self.login_page.login(test_data_success['username'], test_data_success['pwd']) time.sleep(2) # 步骤二:获取实际结果 actual = self.user_page.get_username_text().text # 步骤三:断言 self.assertEqual(actual, test_data_success['expected'])
def __init__(self, driver): self.driver = driver self.userpage = UserPage()
def __init__(self): self.user_page = UserPage()