def login_err13(self, i): """ 输入手机和密码,杀掉进程,启动,数据不存在 """ time.sleep(1.5) self.login_handle.click_account() time.sleep(1.5) self.login_handle.send_username("13728628611") time.sleep(1.5) self.login_handle.send_password("s123456") time.sleep(1) Server().kill_app(i) time.sleep(6) Server().get_start_app(i) time.sleep(6) self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png") self.login_handle.click_account() time.sleep(1) if self.login_handle.get_title_login() != None: print u"登录账号元素存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png") self.login_handle.click_cancel() else: print u"登录账号元素不存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png")
def normal_err12(self, i): """ 输入用户名和密码,切后台,等待5s,在启动,数据存在 """ time.sleep(1.5) self.login_handle.click_account() time.sleep(1.5) if self.login_handle.get_title_login() != None: print u"登录账号元素存在" time.sleep(1.5) self.login_handle.send_password("13728628613") time.sleep(1.5) self.login_handle.send_password("s123456789") time.sleep(1.5) Server().cut_background(i) time.sleep(6) Server().get_start_app(i) time.sleep(6) self.login_handle.click_cancel() time.sleep(2) if self.login_handle.judge_account() != None: print u"账户元素存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png") else: print u"账户元素不存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png") else: print u"登录账号元素不存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png")
def normal_err13(self, i): """ 输入用户名和密码,杀掉进程,在启动,数据不存在,默认显示登录页面 """ time.sleep(1.5) self.login_handle.click_account() time.sleep(1.5) if self.login_handle.get_title_login() != None: print u"登录账号元素存在" time.sleep(1.5) self.login_handle.send_password("13728628613") time.sleep(1.5) self.login_handle.send_password("s123456789") time.sleep(1.5) Server().kill_app(i) time.sleep(6) Server().get_start_app(i) time.sleep(6) if self.login_handle.judge_account() != None: print u"账户元素存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png") else: print u"账户元素不存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png") else: print u"登录账号元素不存在" self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" + str(time.time()) + ".png")
def close_start_app(self, i): """ 杀掉APP进程,再次启动APP """ Server().kill_app(i) time.sleep(2) Server().get_start_app(i) time.sleep(2)
def run(): server = Server() write_user_cmd = WriteUserCmd() server.start_server() print "完成start_server()" devices_length = write_user_cmd.get_file_lines() start_process(main.test_suite.run_suite, devices_length)
def __new__(cls, *args, **kwargs): server = Server() devices = server.device_list ports = server.appium_port_list server.start1() time.sleep(10) if not hasattr(cls, '_instance'): orig = super(BaseDriver, cls) desired_caps = { 'platformName': 'Android', 'platformVersion': '8.1.0', 'deviceName': devices[0], 'appPackage': 'com.nexttao.shopforce.enterprise', 'appActivity': 'com.nexttao.shopforce.fragment.SplashActivity', 'unicodeKeyboard': 'True', 'resetKeyboard': 'True', 'noReset': 'True', 'newCommandTimeout': 60, 'automationName': 'uiautomator2' } cls._instance = orig.__new__(cls) info = 'http://127.0.0.1:%s/wd/hub' % int(ports[0]) # info = 'http://127.0.0.1:4723/wd/hub' cls._instance.driver = webdriver.Remote(info, desired_caps) return cls._instance
def run_method(self): print "start runmethod..." server = Server() server.main() case_data = GetCaseData(0) action_method = ActionMothod(0) lines = case_data.get_case_lines() for i in range(1, lines): handle_step = case_data.get_handle_step(i) element_key = case_data.get_element_key(i) handle_value = case_data.get_handle_value(i) expect_element = case_data.get_except_element(i) expect_step = case_data.get_except_step(i) handle_method = getattr(action_method, handle_step) if element_key != '': handle_method(element_key, handle_value) else: handle_method(handle_value) print u"预期步骤是:" + expect_step if expect_step != '': expect_result = getattr(action_method, expect_step) result = expect_result(expect_element) print result if result: case_data.write_value(i, "pass") print "------------------pass--------------------" else: case_data.write_value(i, "fail") print "------------------fail--------------------"
def run_method(self): server = Server() server.main() data = GetData() action_method = ActionMethod() lines = data.get_case_lines() for i in range(1, lines): handle_step = data.get_handle_step(i) element_key = data.get_element_key(i) handle_value = data.get_handle_value(i) expect_key = data.get_expect_element(i) expect_step = data.get_expect_handle(i) #input() login_button #input str #None excute_method = getattr(action_method, handle_step) if element_key != None: excute_method(element_key, handle_value) else: excute_method(handle_value) if expect_step != None: expect_result = getattr(action_method, expect_step) result = expect_result(expect_key) if result: data.write_value(i, "passs") else: data.write_value(i, "fail")
def __init__(self): self.server = Server() self.server.main() base_driver = BaseDriver() self.driver = base_driver.android_driver(0) self.data = GetData() self.lines = self.data.get_case_lines()
def run_test(self): server = Server() server.execute_command_on_thread() suite = unittest.TestSuite() my_custom_name = My_Custom_Name() device_list = self.deal_device_info() for device_info in range(len(device_list)): print('device_info:',device_list[device_info]) room_name = device_list[device_info][0] device_name = device_list[device_info][1] model = device_list[device_info][2]
def run_test(self): server = Server() server.execute_command_on_thread() suite = unittest.TestSuite() suite.addTests(unittest.TestLoader().loadTestsFromTestCase(T1)) suite.addTests(unittest.TestLoader().loadTestsFromTestCase(T2)) suite.addTests(unittest.TestLoader().loadTestsFromTestCase(T3)) suite.addTests(unittest.TestLoader().loadTestsFromTestCase(T4)) suite.addTests(unittest.TestLoader().loadTestsFromTestCase(T5)) filename = '../report//HTMLReport.html' with open(filename, 'wb') as f: HTMLTestRunner.HTMLTestRunner(stream=f, title='MathFunc Test Report', description='测试报告详情:').run(suite) server.kill_server()
def run_method(self): # 启动appium服务 server = Server() server.main() # 生成Server data = GetData() action_method = ActionMethod() lines = data.get_case_lines() time.sleep(5) for i in range(1, lines): handle_step = data.get_handle_step(i) element_key = data.get_element_key(i) handle_value = data.get_handle_value(i) expect_key = data.get_expect_element(i) expect_step = data.get_expect_handle(i) excute_method = getattr(action_method, handle_step) if element_key != None: excute_method(element_key, handle_value) else: excute_method(handle_value) if expect_step != None: expect_result = getattr(action_method, expect_step) expect_result(expect_key)
def __init__(self, i): server = Server() server.main() time.sleep(20) #等待appium完全启动 self.action_method = ActionMethod(i)
def appium_init(): server = Server() server.main() time.sleep(20)
def appium_stop(): server = Server() server.kill_server()
def appium_init(): server = Server() server.main("parents")
self.get_data.write_value(i, 'pass') else: self.get_data.write_value(i, 'fail') def rmain(i): rm = RunMain(i) rm.run_method() def get_count(): write_user_command = WriteUserCommand() count = write_user_command.get_file_lines() return count if __name__ == '__main__': Server().main() time.sleep(5) # rm = RunMain() # time.sleep(5) # rm.run_method() process = [] for i in range(get_count()): # 使用多线程需要使用线程锁, 防止线程间数据混乱 t = Process(target=rmain, args=(i,)) process.append(t) # t = multiprocessing.Process(target=get_suite, args=(i, )) # threads.append(t) [t.start() for t in process]
def __init__(self): self.server = Server() self.server.main() self.case_data = GetCaseExcelData() self.action_method = ActionMethod()
def __init__(self): server = Server() server.main() time.sleep(20) operaterYaml = OperateYaml() self.deivces_num = operaterYaml.get_cloumn()
def tearDownClass(cls): print u"= = = = = Close APP = = = = =" cls.action_method.kill_App() #退出APP time.sleep(20) server = Server() server.kill_server() #杀掉appium服务进程
def appium_init(): server = Server() server.main("teacher")
def test_get_device(self): server = Server() device_info = server.get_devices() print(device_info)
suite.addTest(Ctrl_Ln1_V1_Case('test_case25')) suite.addTest(Ctrl_Ln1_V1_Case('test_case26')) suite.addTest(Ctrl_Ln1_V1_Case('test_case27')) suite.addTest(Ctrl_Ln1_V1_Case('test_case28')) suite.addTest(Ctrl_Ln1_V1_Case('test_case29')) suite.addTest(Ctrl_Ln1_V1_Case('test_case30')) suite.addTest(Ctrl_Ln1_V1_Case('test_case31')) suite.addTest(Ctrl_Ln1_V1_Case('test_case32')) suite.addTest(Ctrl_Ln1_V1_Case('test_case33')) suite.addTest(Ctrl_Ln1_V1_Case('test_case34')) # unittest.TextTestRunner().run(suite) # 定义个报告存放的路径,支持相对路径 # filename = '../report/tesecase'+str(i)+'_report'+'.html' # filename = '../report/HTMLReport.html' filename = '/Users/lumi/Documents/items/MIOT/Appium_Android_RPC/report/HTMLReport.html' file_result = open(filename, 'wb') # 定义测试报告 HTMLTestRunner.HTMLTestRunner(stream=file_result, title='Aqara墙壁开关(零火线单键版)测试用例结果', description='测试报告详情:').run(suite) file_result.close() if __name__ == '__main__': server = Server() server.execute_command_on_thread() get_suite() server.kill_server()
def appium_init(): server = Server() server.main()
def __init__(self): self.write_file = WriteUserCommand() self.server = Server()
def start_appium(self, device, appium_port, bootstrap_port): server = Server() server.start_appium(device, appium_port, bootstrap_port) logging.debug("start_appium" + str(device) + str(appium_port) + str(bootstrap_port)) self._success()
def stop_appium(): server = Server() server.kill_server()
def appium_init(): #启动appium server = Server() server.main()
def start_test(self): server = Server() port = server.start_server() driver = Driver() driver.start_driver(port)
def appium_init(): """ 启动appium服务 """ server = Server() server.main() #启动appium服务