class LoginCase(unittest.TestCase): def setUp(self): self.driver = BrowserDriver(object).open_browser( "Chrome", "http://172.23.23.223:8080/yclpt") self.driver.maximize_window() self.login = LoginBusiness(self.driver) def tearDown(self): for method_name, error in self._outcome.errors: if error: case_name = str(method_name).split("(")[0] ScreenShot(self.driver).shot(case_name) self.driver.close() def test_login_username_error(self): username_error = self.login.login_username_error("aaa", "123456Aa") self.assertTrue(username_error, "用例执行失败") def test_login_password_error(self): password_error = self.login.login_password_error("wangq", "123456789") self.assertTrue(password_error, "用例执行失败") def test_login_success(self): message = self.login.login_success("songll", "12345678Aa") self.assertTrue(message, "用例执行失败")
def setUpClass(self): self.driver = BrowserDriver(object).open_browser( "Chrome", "http://172.23.23.223:8080/yclpt") self.driver.maximize_window() self.login = LoginBusiness(self.driver) self.ptsw = PtswBuiness(self.driver) self.login.login_base("songll", "12345678Aa")
def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://passport.baidu.com/v2/?login') #访问百度用户登录界面 self.driver.refresh() self.driver.maximize_window() self.login = LoginBusiness(self.driver) self.driver.implicitly_wait(5)
def __init__(self, i): base_driver = BaseDriver() self.driver = base_driver.android_driver(i) self.login_business = LoginBusiness(self.driver) self.account_business = AccountBusiness(self.driver) self.registration_business = RegistrationBusiness(self.driver) self.closes_app = ClosesApp(self.driver)
class Test_LoginCase(object): def setup(self): self.driver = webdriver.Chrome() self.driver.get('https://gitee.com/login') self.login_b =LoginBusiness(self.driver) def teardown(self): self.driver.close() def _test_login_emp(self): result = self.login_b.login_name_error('123','') if result == True: print('用例执行成功,登录失败') def _test_login_name_err(self): result = self.login_b.login_name_error('1234','1234567') if result == True: print('用例执行成功,登录失败') def _test_login_password_err(self): result = self.login_b.login_name_error('selenium_training','123') print('***********login_password************') if result == True: print('用例执行成功,登录失败') def test_login_succ(self): self.login_b.login_success('selenium_training', 'test123456')
class LoginCase(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://gitee.com/login') self.login_b = LoginBusiness(self.driver) def tearDown(self): time.sleep(2) for method_name, error in self._outcome.errors: print('method_name: ', method_name, 'error:', error) if error: case_name = self._testMethodName img_name = os.path.join(os.getcwd() + '/report/screenshot/' + case_name + '.png') print('img_name: ', img_name) self.driver.get_screenshot_as_file(img_name) self.driver.close() def _test_login_emp(self): result = self.login_b.login_name_error('123', '') self.assertFalse(result) def _test_login_name_err(self): result = self.login_b.login_name_error('1234', '1234567') self.assertFalse(result) def test_login_password_err(self): result = self.login_b.login_name_error('selenium_training', '123') self.assertFalse(result) def test_login_succ(self): succ = self.login_b.login_success('selenium_training', 'test123456') self.assertTrue(succ)
def test_00(self): print('this is test_00') print('传入的参数'+str(parames)) appPackage = "cn.com.open.mooc" appActivity = "com.imooc.component.imoocmain.splash.MCSplashActivity" self.login_business = LoginBusiness(parames,appPackage,appActivity) time.sleep(5) self.login_business.main()
class PtswCase(unittest.TestCase): @classmethod def setUpClass(self): self.driver = BrowserDriver(object).open_browser( "Chrome", "http://172.23.23.223:8080/yclpt") self.driver.maximize_window() self.login = LoginBusiness(self.driver) self.ptsw = PtswBuiness(self.driver) self.login.login_base("songll", "12345678Aa") @classmethod def tearDownClass(self): self.driver.quit() def tearDown(self): for method_name, error in self._outcome.errors: if error: case_name = str(method_name).split("(")[0] ScreenShot(self.driver).shot(case_name) #self.driver.close() def test_ptsw_save(self): bt = "savetest" + str(random.randint(0, 999)) lwhm = time.strftime("%m%d%H%M%S", time.localtime()) + "号" file_path = "C:\\Users\\huayu\\Desktop\\nmon16e_mpginc.tar.gz" #file_path = "D:\\baiduNetDiskDownload\\test.txt" action = "save" self.ptsw.ptsw_save(bt, file_path, action, lwdw="上海", lwh="沪", lwhm=lwhm, btlx='nbd', fs="20", bq="标签") result = self.ptsw.check(bt, "nbd") self.assertTrue(result, "收文单新建失败") def ptsw_send(self): bt = "sendtest" + str(random.randint(0, 999)) lwhm = time.strftime("%m%d%H%M%S", time.localtime()) + "号" file_path = "C:\\Users\\huayu\\Desktop\\nmon16e_mpginc.tar.gz" #file_path = "D:\\baiduNetDiskDownload\\test.txt" action = "send" self.ptsw.ptsw_save(bt, file_path, action, lwdw="上海", lwh="沪", lwhm=lwhm, btlx='psj', fs="20", bq="标签")
def setUpClass(cls, value='https://www.baidu.com'): cls.driver = webdriver.Chrome() cls.driver.get(value) cls.driver.maximize_window() cls.driver.implicitly_wait(30) cls.log = Log() cls.login_business = LoginBusiness(cls.driver)
def setUpClass(cls): # print("setUpclass---->", str(parames)) get_driver = BaseDriver() cls.driver = get_driver.android_driver(parames) cls.scanner_business = ScannerBusiness(cls.driver) cls.main_business = MainBusiness(cls.driver) cls.login_business = LoginBusiness(cls.driver)
def setUpClass(cls): print('所有case执行的前置条件') cls.login_url = 'http://localhost:9090/exam-place/login' cls.driver = webdriver.Firefox() cls.driver.get(cls.login_url) cls.driver.maximize_window() cls.lb = LoginBusiness(cls.driver)
def setUpClass(cls): cls.driver = Driver().android_driver(0) cls.login = LoginBusiness(cls.driver) cls.homepage = HomePage(cls.driver) cls.txt = WriteTxt() cls.driver.implicitly_wait(15) cls.login.username_login_pass()
class ActionMethod(object): def __init__(self, i): base_driver = BaseDriver() self.driver = base_driver.android_driver(i) self.login_business = LoginBusiness(self.driver) self.account_business = AccountBusiness(self.driver) self.registration_business = RegistrationBusiness(self.driver) self.closes_app = ClosesApp(self.driver) def kill_App(self): self.closes_app.closes_quites() def action_login_001(self, i): '''判断启动页面的轮播元素是都存在''' try: self.login_business.login_judge01(i) except Exception, e: print u"用例失败:" + e else:
class LoginTest(unittest.TestCase): @classmethod def setUpClass(self): self.driver = webdriver.Chrome() self.driver.get("https://h5-qa.admin.yuedaowang.com/#/driverSettle") self.login_busi = LoginBusiness(self.driver) #用户名错误 def test_login_error_user(self): login_user = self.login_busi.login_user_error() if login_user == True: print("用户名错误,登录失败,此条case执行失败") #密码错误 def test_login_errorb_pwd(self): login_pwd = self.login_busi.login_pwd_error() if login_pwd == True: print("密码错误,登录失败,此条case执行失败") #登录成功 def test_login_success(self): success = self.login_busi.login_success() if success == True: print('登录成功')
class LoginCase(unittest.TestCase): @classmethod def setUpClass(cls): cls.logger = log() cls.log_config = cls.logger.get_log() def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://gitee.com/login') self.log_config.debug('创建driver') self.login_b = LoginBusiness(self.driver) def tearDown(self): time.sleep(2) for method_name, error in self._outcome.errors: print('method_name: ', method_name, 'error:', error) if error: case_name = self._testMethodName img_name = os.path.join(os.getcwd() + '/report/screenshot/' + case_name + '.png') print('img_name: ', img_name) self.driver.get_screenshot_as_file(img_name) self.driver.close() @classmethod def tearDownClass(cls): cls.logger.close_handle() # @ddt.data( # ['liliang','dfghjk','name_error','用户名为必填项'], # ['liliang','dfghjk','name_error','用户名为必填项'], # ['liliang', 'dfghjk', 'name_error', '用户名为必填项'], # ) # # @ddt.unpack # def test_login_emp(self,username,password,assertkey,asserttext): # result = self.login_b.login_function(username, password,assertkey,asserttext) # self.assertFalse(result) @ddt.data(*data) def test_login_emp(self, data): username, password, assertkey, asserttext = data result = self.login_b.login_function(username, password, assertkey, asserttext) self.assertFalse(result)
class LoginCase(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.get("https://mail.126.com/") self.driver.maximize_window() self.login = LoginBusiness(self.driver) def tearDown(self): self.driver.close() @ddt.data(["*****@*****.**", "123456", "emailorpw_error", "帐号或密码错误"], ["*****@*****.**", "123456", "emailorpw_error", "帐号或密码错误"], ["*****@*****.**", "", "pw_empty_error", "请输入密码"], ["", "123456", "email_empty_error", "请输入帐号"]) @ddt.unpack def test_login(self, useremail, pw, assertcode, asserttext): email_e = self.login.login_function(useremail, pw, assertcode, asserttext) self.assertTrue(email_e, "测试通过")
def setUpClass(cls): global params print "这个是setupclass里面的参数:", params if params == 0: port = 4723 device = '127.0.0.1:21503' else: port = 4700 device = '127.0.0.1:21523' capabilities = { "platformName": "Android", #"automationName":"UiAutomator2", "deviceName": device, "app": "E:\\PythonAppium\\AutoTestAppium\\apps\\mukewang.apk", "appWaitActivity": "cn.com.open.mooc.user.login.MCLoginActivity", "noReset": "true" } cls.driver = webdriver.Remote( "http://127.0.0.1:" + str(port) + "/wd/hub", capabilities) time.sleep(10) cls.login_business = LoginBusiness(cls.driver)
def setUpClass(cls): print('this is Class setUp', parames) #-------------启动驱动----------------- capabilites = { "platformName": "Android", "deviceName": "emulator-5554", #//模拟器0 "newCommandTimeout": "0", "app": "D:\Github\Automator_for_Appium_python\Code_PO\Test_APK/fxjc-app-prod-20180911-debug-signed-new.apk", "appWaitActivity": "com.mapass.example.activity.MainActivity_", "noReset": "true", #//关闭每次运行脚本都重新安装APP } driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", capabilites) cls.login_business = LoginBusiness(driver) cls.setup_business = SetupBusiness(driver) cls.tools_business = ToolsBusiness(driver) cls.cards_business = CardsBusiness(driver) cls.service_business = ServiceBusiness(driver) cls.stage_business = StageBusiness(driver) cls.finance_business = FinanceBusiness(driver) CaseTest.case_num = 0
def css_test(self): driver = BrowserDriver(object).open_browser( "Chrome", "http://172.23.22.179:8080/yclpt") #driver = BrowserDriver(object).open_browser("home", "http://172.23.22.179:8080/yclpt") driver.maximize_window() LoginBusiness(driver).login_base("songll", "12345678Aa") driver.implicitly_wait(10) IndexHandle(driver).click_ptsw() c = driver.current_window_handle windows = driver.window_handles print(c) print(windows) driver.switch_to.window(windows[-1]) print(driver.current_window_handle) print(driver.title) #js = 'swdjVo.cbt=1231321' #driver.execute_script(js) #time.sleep(2) #css = 'css selector' #FindElement(driver, "SwdjElement").get_element("swh").click() #time.sleep(1) # msg = driver.find_element_by_xpath('//ul[@class="aty-select-dropdown-list"][2]') #FindElement(driver, "SwdjElement").get_element("swhlist").click() msg = FindElement(driver, "SwdjElement").get_element("yysx") #time.sleep(2) #msg = driver.find_element_by_xpath('//ul[@class="aty-select-dropdown-list"][2]') #FindElement(driver, "SwdjElement").get_element("mjlist").click() #FindElement(driver, "SwdjElement").get_element("swh").click() #FindElement(driver, "SwdjElement").get_element("swhlist").click() #FindElement(driver, "SwdjElement").get_element("lwdw").send_keys("上海") #time.sleep(3) #FindElement(driver, "SwdjElement").get_element("lwdwlist").click() #msg = driver.find_element_by_xpath("//div[contains(@class,'lwdw')]/ul/li[1]") #FindElement(driver, "SwdjElement").get_element("mj").click() #time.sleep(1) #msg = driver.find_element_by_xpath("//div[contains(@class,'lwdw')]/ul/li[1]") #msg = FindElement(driver, "SwdjElement").get_element("mjlist") print(msg) time.sleep(3)
class FirstDdtCase(unittest.TestCase): # @classmethod # def setUpClass(cls): def setUp(self): self.driver = webdriver.Chrome() self.driver.get('https://passport.baidu.com/v2/?login') #访问百度用户登录界面 self.driver.refresh() self.driver.maximize_window() self.login = LoginBusiness(self.driver) self.driver.implicitly_wait(5) # self.login = RegisterBusiness(self.driver) def tearDown(self): for method_name, error in self._outcome.errors: # case如果执行失败,错误会保存到_outcome.errors 中 if error: case_name = self._testMethodName # case名,即定义好的方法名 report_error_name = case_name + '.png' report_error_path = os.path.join(setting.report_path, 'screenshot', report_error_name) self.driver.save_screenshot(report_error_path) # self.driver.close() self.driver.quit() # @classmethod # def tearDownClass(cls): # cls.driver.close() @ddt.data(('13068029876', '**********'), ('755318368', '200800lys')) #测试数据 @ddt.unpack def test_login_case(self, username, pwd): # ex_data:[[],[],..] 列表套列表 login_error = self.login.login_error_function(username, pwd) self.assertFalse( login_error, "登录成功,测试失败!") # login_error如果不等于False,表示没有错误信息,登录成功。此条case测试失败
def test(self): driver = BrowserDriver(object).open_browser( "Chrome", "http://172.23.22.179:8080/yclpt") driver.maximize_window() LoginBusiness(driver).login_base("songll", "12345678Aa") driver.implicitly_wait(10) PtswHandle(driver).click_ptsw() windows = driver.window_handles driver.switch_to.window(windows[-1]) js = 'swdjVo.cbt=1231321' driver.execute_script(js) time.sleep(2) FindElement( driver, "SwdjElement").get_element("bt").send_keys("zxcvzxvzxcvxzv") FindElement(driver, "SwdjElement").get_element("swh").click() time.sleep(1) FindElement(driver, "SwdjElement").get_element("swhlist").click() #msg = driver.find_element_by_css_selector(".aty-btn.aty-btn-ghost.aty-btn-icon-only").click() #print(msg) FindElement(driver, "SwdjElement").get_element("bdsc").click() time.sleep(1) UploadFile.upload_one('C:\\Users\\huayu\\Desktop\\bigdata_stdout.log') time.sleep(5)
def setUpClass(cls): print("setupclass---->", params) cls.login_business = LoginBusiness(params)
class CaseTest(ParameTestCase): # 所有case共用只执行一次 @classmethod def setUpClass(cls): ''' cls.login_business = LoginBusiness(parames) print(parames) ''' print('this is class') # 一个case的开启语 def setUp(self): print('测试用例开始执行+++++++++++++++++++++++++++++') # 一个case的结束语 def tearDown(self): print('测试用例执行结束+++++++++++++++++++++++++++++') #下载收藏视频 def test_00(self): print('this is test_00') print('传入的参数'+str(parames)) appPackage = "cn.com.open.mooc" appActivity = "com.imooc.component.imoocmain.splash.MCSplashActivity" self.login_business = LoginBusiness(parames,appPackage,appActivity) time.sleep(5) self.login_business.main() def test_01(self): self.show_ui() #显示UI def show_ui(self): img_folder = "/Users/kang/Desktop/phone0/0.png" monitor_class = Monitor() frame = monitor_class.start_ui(img_folder) #显示UI def show_ui_1(self): img_folder = "/Users/kang/Desktop/phone1/1.png" monitor_class = Monitor() frame = monitor_class.start_ui(img_folder) #显示UI def show_ui_2(self): img_folder = "/Users/kang/Desktop/phone2/2.png" monitor_class = Monitor() frame = monitor_class.start_ui(img_folder) #下载朋友圈信息 def test_02(self): print('this is test_00') print('传入的参数' + str(parames)) appPackage = "com.tencent.mm" appActivity = "com.tencent.mm.ui.LauncherUI" self.doload_friend_info = DoloadFriendInfo(parames, appPackage, appActivity) time.sleep(5) self.doload_friend_info.main_friend() def test_03(self): self.show_ui_1() #优酷提交视频 def test_04(self): print('传入的参数' + str(parames)) appPackage = "com.youku.phone" appActivity = "com.youku.phone.ActivityWelcome" self.login_business_second = LoginBusinessSecond(parames, appPackage, appActivity) time.sleep(2) self.login_business_second.main() def test_05(self): self.show_ui_2()
driver.find_element_by_id("com.heshidai.app:id/et_regist_phonenum").send_keys("13728628698") driver.find_element_by_id("com.heshidai.app:id/bt_regist_getmsgcode").click() driver.find_element_by_id("com.heshidai.app:id/et_regist_writecode").send_keys(getcode()) time.sleep(2) driver.find_element_by_id("com.heshidai.app:id/tv_regist_model_start").click() driver.find_element_by_id("com.heshidai.app:id/regist_commit_msgcode").click() driver.find_element_by_id("com.heshidai.app:id/et_regist_passwd").send_keys("s123456") driver.find_element_by_id("com.heshidai.app:id/regist_commit_succ").click() login_buess = LoginBusiness(driver) login_buess.gesture_password() time.sleep(10) driver.close_app() '''
def setUpClass(cls): print "setUpclass---->", parames cls.login_business = LoginBusiness(parames)
def setUpClass(cls): port = 4723 device = '127.0.0.1:21503' cls.driver = Base_Driver.get_driver(device) time.sleep(5) cls.login_business = LoginBusiness(cls.driver)
class LoginApp(unittest.TestCase): def setUp(self): self.driver = Driver().android_driver(0) self.login = LoginBusiness(self.driver) self.txt = WriteTxt() self.homepage = HomePage(self.driver) self.driver.implicitly_wait(15) def tearDown(self): driver = self.driver driver.quit() def test_login_success(self): ''' :condition:用户用户登陆页面 :step:输入正确的用户名和密码登陆 :except:用户能够登陆成功 ''' self.login.username_login_pass() market = self.homepage.get_market_tab_element().text print(market) try: self.assertEqual(market, '行情', msg='登陆成功') except: self.txt.write_data('fail') raise else: self.txt.write_data('pass') def test_login_username_error(self): ''' :condition:用户在登陆页面 :step:用户名输入错误,密码输入正确 :except:用户不能够登陆成功 ''' self.login.username_login_username_error() market = self.homepage.get_market_tab_element() try: self.assertIsNone(market, msg='登陆失败') except: self.txt.write_data('fail') raise else: self.txt.write_data('pass') def test_login_password_error(self): ''' :condition:用户在登陆页面 :step:用户名输入正确,密码输入错误 :except:用户不能够登陆成功 ''' self.login.username_login_password_error() market = self.homepage.get_market_tab_element() try: self.assertIsNone(market, msg='登陆失败') except: self.txt.write_data('fail') raise else: self.txt.write_data('pass') def test_mt4_login_pass(self): ''' :condition:用户在MT4登陆页面 :step:mt4输入正确,密码输入正确 :except:用户能够登陆成功 ''' self.login.mt4_login_pass('AETOS-LIVE') market = self.homepage.get_market_tab_element().text print(market) try: self.assertEqual(market, u'行情', msg='登陆成功') except: self.txt.write_data('fail') raise else: self.txt.write_data('pass') def test_mt4_login_mt4_error(self): ''' :condition:用户在MT4登陆页面 :step:mt4输入错误,密码输入正确 :except:用户登陆不成功 ''' self.login.mt4_login_mt4_error('AETOS-LIVE') market = self.homepage.get_market_tab_element() try: self.assertIsNone(market, msg='登陆失败') except: self.txt.write_data('fail') raise else: self.txt.write_data('pass') def test_mt4_login_pwd_error(self): ''' :condition:用户在MT4登陆页面 :step:mt4输入正确,密码输入错误 :except:用户登陆不成功 ''' self.login.mt4_login_pwd_error('AETOS-LIVE') market = self.homepage.get_market_tab_element() try: self.assertIsNone(market, msg='登陆失败') except: self.txt.write_data('fail') raise else: self.txt.write_data('pass')
def setUp(self): self.driver = Driver().android_driver(0) self.login = LoginBusiness(self.driver) self.txt = WriteTxt() self.homepage = HomePage(self.driver) self.driver.implicitly_wait(15)
def __init__(self): driver = webdriver.Chrome() driver.get('https://gitee.com/login') self.login_b = LoginBusiness(driver)
def setUpClass(cls): print('setUpClass------->', parames) cls.login_business = LoginBusiness(parames) cls.run_main = RunMain(parames)