示例#1
0
def tools_main_run():
    parser = argparse.ArgumentParser(
        description="Get devices info and get apk info.")

    parser.add_argument('--apk', help="apk file path.")

    parser.add_argument(
        '--adb',
        default='adb',
        help="set the `adb` path if ANDROID_HOME not configured. default: adb "
    )

    parser.add_argument(
        '--aapt',
        default='aapt',
        help=
        "set the `aapt` path if ANDROID_HOME not configured. default: aapt ")

    color_print("appuidriver {}".format(__version__), "GREEN")

    args = parser.parse_args()

    if args.apk:
        print(
            Android.gen_capabilities(apk_abs_path=args.apk,
                                     aapt_exe_4path=args.aapt))
    else:
        devices = Android.get_devices(args.adb)
        print(devices)
示例#2
0
    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)
示例#3
0
    def test_get_devices(self):
        devices = Android.get_devices(self._adb_exe_path)
        #print("devices:",devices)

        if devices:
            device_id, properties = devices.popitem()
            self.assertIsNotNone(device_id)
            for prop in ("model", "linux_version", "ip", "cpu",
                         "android_version", "pad_version"):
                self.assertIn(prop, properties)
        else:
            self.assertIsInstance(devices, dict)
示例#4
0
    def __init__(self):
        super(LocalDriver, self).__init__(is_local_driver=True)
        desired_cap = Android.gen_capabilities(
            apk_abs_path=LocalDriver._apk_abs_path,
            app_package=LocalDriver._app_package,
            app_activity=LocalDriver._app_activity,
            aapt_exe_4path=LocalDriver._aapt_exe_path)

        devices = Android.get_devices(LocalDriver._adb_exe_path)
        device_id, properties = devices.popitem()
        desired_cap["deviceName"] = device_id
        desired_cap["platformVersion"] = properties.get('android_version')

        self._default_drivers = [
            ("",
             Android.gen_remote_driver(executor=Android.get_executor(
                 "localhost", 4723),
                                       capabilities=desired_cap))
        ]
示例#5
0
    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()