def appium_main_run(): parser = argparse.ArgumentParser(description="appium server command line.") parser.add_argument( 'address', help= "appium server address, loopback address not suggest to use if grid mode. e.g. 192.168.1.1:4723" ) parser.add_argument( '--device-name', help="android device name. bind device to appium. e.g. HuaWei p10 plus" ) parser.add_argument( '--device-version', help= "android device platform version. bind device platform version to appium. e.g. 4.4.4" ) parser.add_argument( '--hub-ip', help="hub ip address in grid mode. register current appium to hub.") parser.add_argument( '--hub-port', type=int, default=4444, help= "hub port in grid mode. register current appium to hub. default: 4444") parser.add_argument( '--chromedriver-executable', help= "ChromeDriver executable full path for webview. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more detail" ) color_print("appuidriver {}".format(__version__), "GREEN") args = parser.parse_args() if len(args.address.split(":", 1)) < 2: return "command parameter error." ip, port = args.address.split(":", 1) server = AppiumJs(port=int(port)) if args.chromedriver_executable: server.appium_cmd.extend( ["--chromedriver-executable", args.chromedriver_executable]) if args.device_name: server.bind_device(device_id=args.device_name, platform_version=args.device_version) if args.hub_ip: server.node(ip, hub_address=(args.hub_ip, args.hub_port)).start_server() server.start_server()
def test_LocalDriver_with_datadriver(self): LocalDriver._adb_exe_path = self._adb_exe_path LocalDriver._aapt_exe_path = self._aapt_exe_path LocalDriver._apk_abs_path = self._apk_abs_path LocalDriver._app_package = self._app_package LocalDriver._app_activity = self._app_activity server = AppiumJs(port=4723).bind_device(device_id="127.0.0.1:6555", platform_version="4.4.4") server.start_server() runner = TestRunner(runner=LocalDriver).run(self.data_driver_case) html_report = runner.gen_html_report() print(html_report) self.assertIsInstance(html_report, (list, tuple))
def setUpClass(cls): ''' @note: adb version 1.0.39; %ANDROID_HOME% = D:\auto\buffer\test\test_rtsf_web\android; 天天模拟器 v2.5.6 ''' platform_tools = r'C:\d_disk\auto\buffer\test\tools\android\platform-tools' cls._adb_exe_path = os.path.join(platform_tools, "adb.exe") cls._aapt_exe_path = os.path.join(platform_tools, "aapt.exe") cls._apk_abs_path = r'C:\d_disk\auto\buffer\test\tools\android\ApiDemos-debug.apk' cls.server = AppiumJs(port=4723).bind_device( device_id="127.0.0.1:6555") cls.server.start_server() devices = Android.get_devices(cls._adb_exe_path) device_id, properties = devices.popitem() desired_cap = Android.gen_capabilities( apk_abs_path=cls._apk_abs_path, aapt_exe_4path=cls._aapt_exe_path) desired_cap["deviceName"] = device_id desired_cap["platformVersion"] = properties.get('android_version') # desired_cap = { # 'platformName': 'Android', # 'deviceName': '127.0.0.1:6555', # 'platformVersion': '4.4.4', # 'app': 'C: \\d_disk\\auto\\buffer\\test\\tools\\android\\ApiDemos-debug.apk', # 'appPackage': 'io.appium.android.apis', # 'appWaitPackage': 'io.appium.android.apis', # 'appActivity': 'io.appium.android.apis.ApiDemos', # 'unicodeKeyboard': True, # 'resetKeyboard': True, # 'newCommandTimeout':120000, # } App.driver = Android.gen_remote_driver(executor=Android.get_executor( "127.0.0.1", 4723), capabilities=desired_cap)
def test_gen_remote_driver(self): server = AppiumJs(port=4723).bind_device(device_id="127.0.0.1:6555") server.start_server() desired_cap = Android.gen_capabilities( apk_abs_path=self._apk_abs_path, aapt_exe_4path=self._aapt_exe_path) self.assertIsInstance(desired_cap, dict) devices = Android.get_devices(self._adb_exe_path) self.assertIsInstance(devices, dict) device_id, properties = devices.popitem() desired_cap["deviceName"] = device_id desired_cap["platformVersion"] = properties.get('android_version') driver = Android.gen_remote_driver(executor=Android.get_executor( "localhost", 4723), capabilities=desired_cap) driver.quit() server.stop_server()
def test_RemoteDriver(self): RemoteDriver._aapt_exe_path = self._aapt_exe_path RemoteDriver._apk_abs_path = self._apk_abs_path RemoteDriver._app_package = self._app_package RemoteDriver._app_activity = self._app_activity hub = SeleniumJar(self.jar_path, self.java_path).hub(4444) hub.start_server() node = AppiumJs(port=4723).bind_device( device_id="127.0.0.1:6555", platform_version="4.4.4").node("localhost", hub_address=("localhost", 4444)) node.start_server() runner = TestRunner(runner=RemoteDriver).run(self.case_file) html_report = runner.gen_html_report() print(html_report) self.assertIsInstance(html_report, (list, tuple)) node.stop_server() hub.stop_server()
def test_gen_remote_driver_grid(self): self._hub.start_server() device_name = "127.0.0.1:6555" device_version = "4.4.4" node_ip = "localhost" port = 4723 server = AppiumJs(port=port).bind_device( device_id=device_name, platform_version=device_version).node(node_ip, hub_address=("localhost", 4444)) server.start_server() drivers = [] desired_cap = Android.gen_capabilities( apk_abs_path=self._apk_abs_path, aapt_exe_4path=self._aapt_exe_path) executors = Android.get_remote_executors(hub_ip="localhost", port=4444) for udid, udversion, executor in executors: cap = desired_cap.copy() cap["deviceName"] = udid cap["platformVersion"] = udversion driver = Android.gen_remote_driver(executor=executor, capabilities=cap) drivers.append(driver) driver.quit() self.assertEqual(len(drivers), 1) self.assertEqual(udid, device_name) self.assertEqual(udversion, device_version) self.assertEqual(executor, "http://{}:{}/wd/hub".format(node_ip, port)) server.stop_server() self._hub.stop_server()