def logintoapp(self): loginpage = LoginPage(self.driver) loginpage.loginDashboard() # self.username = loginpage.usernameText appicon = IconListPage(self.driver) appicon.click_threatstream() sleep(20)
def setUp(self): self.dr = my_driver() self.lg = LoginPage(self.dr) self.lg.login(username='******', password='******', yanzhengma='1') self.mp = MyacountPage(self.dr) self.mp.draw_btn() self.dp = DrawcashPage(self.dr)
class logintest(unittest.TestCase): @classmethod def setUpClass(cls): #cls.mysql_host = getBrowserName(Mysql_Host) #cls.redis_host = getBrowserName(Redis_Host) #cls.url = getBrowserName(Url) pass def setUp(self): pre = BrowserStart() #self.driver = pre[0] #self.url = pre[1] self.loginpage = LoginPage(pre[0],pre[1]) def test_login_1(self): ''' DataSet1:数据类型为元祖 该测试用例 css选择器 xpath url等数据 DataSet2:数据类型为元祖 对界面需要进行输入的数据 ''' #ttbar-login > a.link-login DataSet1 = ['#ttbar-login > a.link-login','#content > div > div.w > div > div.login-tab.login-tab-r > a','#loginname','#nloginpwd','#loginsubmit'] DataSet2 = ['京东账号','京东密码'] self.loginpage.click_login(DataSet1[0]) logger.info('点击进入登陆页面') self.loginpage.click_login(DataSet1[1]) logger.info('点击账户登陆') self.loginpage.input_username(DataSet2[0],DataSet1[2]) #logger.info('输入账号') self.loginpage.input_pwd(DataSet2[1],DataSet1[3]) #logger.info('输入密码') self.loginpage.click_login(DataSet1[4]) logger.info('进行登陆')
class DrawcashTest(unittest.TestCase): def setUp(self): self.dr = my_driver() self.lg = LoginPage(self.dr) self.lg.login(username='******', password='******', yanzhengma='1') self.mp = MyacountPage(self.dr) self.mp.draw_btn() self.dp = DrawcashPage(self.dr) def test1_drawcash_success(self): """提现成功""" self.dp.drawcash(drawamount='10') self.dp.huishang_queren() time.sleep(3) text = self.dp.drawsuccess_text() print(text) self.assertEqual(text, '交易成功!') def test2_drawcash_less10(self): """提现低于最少提现金额10元""" self.dp.drawcash(drawamount='3') text_error = self.dp.drawfail_text() print(text_error) self.assertEqual(text_error, '提现申请失败!单笔提现金额最低10.0元!') def test3_drawcash_error(self): """提现金额大于可用余额""" text = float(self.dp.availableamount()) #可用余额 print(text) amount3 = str(text + 1) print(amount3) self.dp.drawcash(drawamount=amount3) text = self.dp.drawinput_error() self.assertEqual(text, '账户余额不足')
class RechargeTest(unittest.TestCase): def setUp(self): self.dr = my_driver() self.lg = LoginPage(self.dr) self.mp = MyacountPage(self.dr) self.rp = RechargePage(self.dr) self.sp = SumapayPage(self.dr) def test1_recharge_success(self): """充值成功""" self.lg.login(username='******', password='******', yanzhengma='1') amount_before = float(self.mp.avaliable_amount().replace(',', '')) print(amount_before) self.mp.account_pay() sreach_windows = self.dr.current_window_handle #获取当前窗口句柄 print(sreach_windows) self.rp.recharge(money='10') all_handles = self.dr.window_handles #获取所有窗口句柄 #进入输入测试卡号窗口 for handle in all_handles: if handle != sreach_windows: self.dr.switch_to.window(handle) self.sp.sumapay() time.sleep(8) #self.dr.switch_to.window(sreach_windows) #返回主窗口 self.mp.open() amount_after = float(self.mp.avaliable_amount().replace(',', '')) print(amount_after) recharge_amount = int(amount_after - amount_before) self.assertEqual(recharge_amount, 10)
def setUp(self): self.driver = WebDriver( desired_capabilities=DesiredCapabilities.CHROME, command_executor=command_executor) self.driver.get("https://localhost/console") login_page = LoginPage(self.driver).open() login_page.login('*****@*****.**', 'password')
class TestLogin(unittest.TestCase): @classmethod def setUpClass(self): self.dr = driver.browser() self.dr.maximize_window() self.login_p = LoginPage(self.dr) @parameterized.expand([ ("pwd_error", "1445854699", "14458524699", "用户名或密码不正确"), ("user_error", "14458524699", "1448524699", "用户名或密码不正确") ]) #参数化用例,登录失败情况 def test_login(self, name, username, password, assert_text): self.login_p.login_action(username, password) error_text = self.login_p.alert_error().text print(error_text) self.assertEqual(error_text, assert_text) #登录成功 def test_login_success(self): #login_p = LoginPage(self.dr) myacount_p = self.login_p.login_action("wq1qaz_", "wq15803863660") print(self.dr.current_url) #myacount_p = MyacountPage(self.dr) #time.sleep(3) assert_text = myacount_p.login_success_text().text print(assert_text) self.assertEqual(u"账户总览", assert_text, msg="++++++++++++++") # def test_error(self): # raise Exception("为了能完整发送邮件,运行到这,说明没问题,请忽略这条错误信息") """ #用户名、密码输入为空,系统提示输入用户名与密码 def test_null_username_password(self): #login_p = LoginPage(self.dr) self.login_p.login_action("", "") null_username_text = self.login_p.null_username().text null_password_text = self.login_p.null_password().text self.assertIn(u"用户名或手机号", null_username_text) self.assertIn(u"填写密码", null_password_text) #用户名输入为空,密码正确输入,系统提示输入用户名 def test_null_username(self): #login_p = LoginPage(self.dr) self.login_p.login_action("", "123456") null_username_text = self.login_p.null_username().text self.assertIn(u"用户名或手机号", null_username_text) #用户名正确输入,密码输入为空,系统提示输入密码 def test_null_passoword(self): #login_p = LoginPage(self.dr) self.login_p.login_action("wq1qaz_", "") null_password_text = self.login_p.null_password().text self.assertIn(u"填写密码", null_password_text) """ @classmethod def tearDownClass(self): self.dr.quit()
def setUpClass(self): self.dr = driver.browser() self.dr.maximize_window() #调用登录方法 login_p = LoginPage(self.dr) login_p.login_action("15658524692", "wq123456") #time.sleep(3) self.touzi_p = ZhitouxqPage(self.dr)
def setUpClass(self): self.dr = my_driver() self.lg = LoginPage(self.dr) self.mp = MyacountPage(self.dr) self.lg.open() self.lg.login(username='******', password='******', yanzhengma='1') time.sleep(3)
class LoanUserInfoTest(unittest.TestCase): @classmethod def setUpClass(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() self.loanuserinfo_p = self.createpro_p.loanuserinfo() self.loanuserinfo_p.submitform() self.LU = LoanUserInfo(self.dr) @parameterized.expand([ ('test_nativeProvince', 'get_nativeProvince', 'nativeProvince'), ('test_companyEntryTime', 'get_companyEntryTime', 'companyEntryTime'), ('test_currentAddress', 'get_currentAddress', 'currentAddress'), ('test_ethnic', 'get_ethnic', 'ethnic'), ('test_educationLevel', 'get_educationLevel', 'educationLevel'), ('test_maritalStatus', 'get_maritalStatus', 'maritalStatus'), ('test_yearOfService', 'get_yearOfService', 'yearOfService'), ('test_get_quarters', 'get_quarters', 'quarters'), ('test_natureOfCompany', 'get_natureOfCompany', 'natureOfCompany'), ('test_get_industry', 'get_industry', 'industry'), ('test_get_wage', 'get_wage', 'wage'), ('test_get_province', 'get_province', 'province'), ('test_get_city', 'get_city', 'city'), ]) def test_loanuserinfo(self, name, method, data): """借款人信息保存成功""" self.assertEqual(self.LU.get_all_loanuserinfo(method), GetData[data].value) # def test_companyEntryTime(self): # self.assertEqual(self.LU.get_companyEntryTime(), GetData.companyEntryTime.value) # self.assertEqual(self.LU.get_currentAddress(), GetData.currentAddress.value) # self.assertEqual(self.LU.get_ethnic(), GetData.ethnic.value) # self.assertEqual(self.LU.get_educationLevel(), GetData.educationLevel.value) # self.assertEqual(self.LU.get_maritalStatus(), GetData.maritalStatus.value) # self.assertEqual(self.LU.get_yearOfService(), GetData.yearOfService.value) # self.assertEqual(self.LU.get_quarters(), GetData.quarters.value) # self.assertEqual(self.LU.get_natureOfCompany(), GetData.natureOfCompany.value) # self.assertEqual(self.LU.get_industry(), GetData.industry.value) # self.assertEqual(self.LU.get_wage(), GetData.wage.value) # self.assertEqual(self.LU.get_province(), GetData.province.value) # self.assertEqual(self.LU.get_city(), GetData.city.value) @classmethod def tearDownClass(self): self.dr.quit()
def setUp(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject()
def test_login(self): driver = self.driver driver.get(utils.URL) login = LoginPage(driver) login.enter_username(utils.USERNAME) login.enter_password(utils.PASSWORD) login.click_login()
def setUpClass(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() self.loanuserinfo_p = self.createpro_p.loanuserinfo() self.loanuserinfo_p.submitform() self.LU = LoanUserInfo(self.dr)
class webTest(unittest.TestCase): def setUp(self): # 初始化 self.driver = webdriver.Chrome() self.driver.implicitly_wait(10) self.cp = CoursePage(self.driver) self.lp = LoginPage(self.driver) def test(self): # 用例主体 self.lp.login('auto', 'sdfsdfsdf') self.cp.deleteAllCourse() self.cp.add_course('初中语文', '语文课', '1') def tearDown(self): # 清除环境 self.cp.deleteAllCourse() self.driver.close()
def get_login_page(self): if not self.is_logged_in(): elem = Element(self._browser, self._config.get_locator('login_link')) elem.click() return LoginPage(self._browser) return self
def dashboard(request): """ Logins in to leap and lands on the dashboard page to be used by an entire test class Cannot use a login_page fixture as an argument as the scope is different """ with webdriver.Chrome() as driver: driver.get(LOGIN_URL) login_page = LoginPage(driver) login_page.login(USERNAME, PASSWORD) dashboard = DashboardPage(login_page.driver) request.cls.dashboard = dashboard # Yield here to prevent the window from being closed before the test is actually run yield
def webPageChange(self, pagex): if pagex == 0: print("Instagram") elif pagex == 1: print("Facebook") else: print("Twitter") LoginPage(self.leadlayout, self.buttonsettings, pagex)
def login_page(request): """Opens a login page instance to be used by each function""" with webdriver.Chrome() as driver: driver.get(LOGIN_URL) login_page = LoginPage(driver) request.instance.login_page = login_page # Yield here to prevent the window from being closed before the test is actually run yield
def test_edit(self): loginpage = LoginPage(self.driver) loginpage.login("yujiezhang", "yujiezhang") time.sleep(5) assert "graph" in self.driver.current_url, "登录失败!" temppage = TemplatePage(self.driver) temppage.click_document_radio() temppage.click_editbtn("测试") time.sleep(3) # editpage = EditPageLeft(self.driver) # tag = editpage.get_title_tag("导入数据") # tag.click() # time.sleep(3) # editpage.uploadfile("C:\Users\Administrator\Desktop\\testdata.xlsx") # editpage.click_link_oracle() a = EditPageBlank(self.driver) a.click_minbutton("文本域") self.assertEqual(a.get_ctrl_show("文本域").size, {'width': 0, 'height': 0}) time.sleep(5)
def test_template(self): loginpage = LoginPage(self.driver) loginpage.login("yujiezhang", "yujiezhang") time.sleep(5) assert "graph" in self.driver.current_url, "登录失败!" temppage = TemplatePage(self.driver) '''创建空白文档''' temppage.create_newdoc("空白模板", u"测试") editpage = EditPage(self.driver) editpage.click_baocunlable() self.driver.back() time.sleep(3) self.driver.back() time.sleep(5) temppage1 = TemplatePage(self.driver) temppage1.click_document_radio() time.sleep(5) assert u"测试" in self.driver.page_source
class UploadImgTest(unittest.TestCase): def setUp(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() def test_uploadimg(self): self.upload_p = self.createpro_p.uploadimgb() self.upload_p.uploadimage() def tearDown(self): self.dr.quit()
def createdata(driver): login_p = LoginPage(driver) create_p = CreateNew(driver) # 登录操作 login_p.open() login_p.login() # 创建标的 create_p.open() # create_p.createnewproject(project_name="接口测试信3",financingMaturity="1",project_category="企易融", # contractType="企易融_企易融协议",userName="******") create_p.createnewproject(project_name="接口测试信3", financingMaturity="12") # 填写借款人信息 loanuser_p = create_p.loanuserinfo() loanuser_p.submitform() # 上传图片 upload_p = create_p.uploadimgb() upload_p.uploadimage() # 改变项目状态 prosta_p = create_p.projectstatus() prosta_p.changeprosta_yianpai() prosta_p.changeprosta_kaifang() # 获取标id url = driver.current_url project_id = url.split("/")[-1] return project_id
def test_link(self): loginpage = LoginPage(self.driver) loginpage.login("yujiezhang", "yujiezhang") time.sleep(5) assert "graph" in self.driver.current_url, "登录失败!" temppage = TemplatePage(self.driver) temppage.click_document_radio() temppage.click_editbtn("测试") time.sleep(3) editpageleft = EditPageLeft(self.driver) tag = editpageleft.get_title_tag("导入数据") tag.click() # editpageleft.click_link_oracle() # oraclepage = LinkOraclePage(self.driver) # oraclepage.loginoracle("192.168.0.7", "1521", "orcl", "hydata", "hydata") # time.sleep(8) # self.driver.switch_to_alert().accept() # time.sleep(8) editpageleft.click_link_mysql() mysqlpage = LinkMysqlPage(self.driver) mysqlpage.loginmysql("192.168.0.6", "3306", "tueasy", "root", "abc_123456") time.sleep(8)
class ProStatusTest(unittest.TestCase): def setUp(self): self.dr = webdriver.Chrome() self.dr.maximize_window() self.dr.implicitly_wait(10) # 后台需先登录 self.login_p = LoginPage(self.dr) self.login_p.open() self.login_p.login() # 创建新标 self.createpro_p = CreateNew(self.dr) self.createpro_p.open() self.createpro_p.createnewproject() def test_prostatus(self): self.prostat_p = self.createpro_p.projectstatus() self.prostat_p.changeprosta_yianpai() self.prostat_p.changeprosta_kaifang() def tearDown(self): #self.dr.quit() print("end")
def main(): driver=webdriver.Chrome() a=LoginPage(driver) fd=FlashDetailPage(driver) a.open() a.input_username('*****@*****.**') a.input_password('123456') a.click_submit() a.login_wait_check() fd.enter_coupon() fd.enter_flash_menu() fd.click_create_flash_button() fd.create_flash('test','闪购-无sku商品')
def setUp(self): self.dr = my_driver() self.lg = LoginPage(self.dr) self.mp = MyacountPage(self.dr) self.rp = RechargePage(self.dr) self.sp = SumapayPage(self.dr)
def logintoapp(self): self.basepage = BasePage(self.driver) loginpage = LoginPage(self.driver) loginpage.loginDashboard() self.username = loginpage.usernameText self.get_incidents_app()
def logintoapp(self): loginpage = LoginPage(self.driver) loginpage.loginDashboard()
def setUp(self): # 初始化 self.driver = webdriver.Chrome() self.driver.implicitly_wait(10) self.cp = CoursePage(self.driver) self.lp = LoginPage(self.driver)
def setUpClass(self): self.dr = driver.browser() self.dr.maximize_window() self.login_p = LoginPage(self.dr)
from tkinter import * from loginpage import LoginPage from config import Setting root = Tk() root.title("Fru edit") root.iconbitmap(r".\tools\fru.ico") config = Setting() LoginPage(root, config) root.mainloop()
def setUpClass(cls): cls.driver = webdriver.Chrome() login_page = LoginPage(cls.driver) login = Login(cls.driver) cls.goods_detail_page = GoodsDetailPage(cls.driver) login.login()
def setUpClass(cls): cls.driver = webdriver.Chrome() login_page = LoginPage(cls.driver) cls.order_page = OrderPage(cls.driver) login_page.open() login_page.input_username('*****@*****.**') login_page.input_password('123456') login_page.click_submit() login_page.login_wait_check()
def test_user_login(self): login_page = LoginPage(self.driver).open() login_page.login('*****@*****.**', 'password')