How to use the uiautomator2.connect_usb function in uiautomator2

To help you get started, we’ve selected a few uiautomator2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhixideyu / uiautomator2---FaceBook / python-鱼 / xiaomi6.0 / xm_register.py View on Github external
def register():
    try:
        services = 'ebd4f2f67d83'
        start_time = time.time()
        d = u2.connect_usb(services)
        d.screen_off()
        d.screen_on()
        time.sleep(1)
        swipe = Swipeclass(d)
        swipe.swipeUp(d, 0.1)
        time.sleep(3)
        d.app_start('io.virtualapp')
        # d.app_start('com.facebook.katana')
        print('正在启动io.virtualapp')
    except Exception as e:
        print(e)
        sys.exit()
    time.sleep(5)
    print('virtualapp启动成功!')
    time.sleep(5)
    res = d(resourceId="io.virtualapp:id/item_app_name", text=u"Facebook")
github openatx / uiautomator2 / uiautomator2 / webview.py View on Github external
def runtest():
    import uiautomator2 as u2

    d = u2.connect_usb()
    pprint(d.request_agent("/webviews").json())
    port = d._adb_device.forward_port("localabstract:chrome_devtools_remote")
    wd = WebviewDriver(f"http://localhost:{port}")
    tabs = wd.get_active_tab_list()
    pprint(tabs)
github openatx / uiautomator2 / uiautomator2 / webview.py View on Github external
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-t", "--test", action="store_true", help="run test_self_driver")
    args = parser.parse_args()

    # WebviewDriver()
    import uiautomator2 as u2

    d = u2.connect_usb()
    assert d._adb_device, "must connect with usb"
    for socket_path in d.request_agent("/webviews").json():
        port = d._adb_device.forward_port("localabstract:"+socket_path)
        data = requests.get(f"http://localhost:{port}/json/version").json()
        import pprint
        pprint.pprint(data)
github NetEaseGame / ATX / atx / drivers / android.py View on Github external
Raises:
            EnvironmentError
        """
        self.__display = None
        serial = serial or getenvs('ATX_ADB_SERIALNO', 'ANDROID_SERIAL')
        self._host = kwargs.get('host') or getenvs(
            'ATX_ADB_HOST', 'ANDROID_ADB_SERVER_HOST') or '127.0.0.1'
        self._port = int(kwargs.get('port') or getenvs(
            'ATX_ADB_PORT', 'ANDROID_ADB_SERVER_PORT') or 5037)

        self._adb_client = adbkit.Client(self._host, self._port)
        self._adb_device = self._adb_client.device(serial)
        # self._adb_shell_timeout = 30.0 # max adb shell exec time

        # uiautomator2
        self._uiauto = uiautomator2.connect_usb(serial)
        if not self._uiauto.alive:
            self._uiauto.healthcheck(unlock=False)

        DeviceMixin.__init__(self)
        self._randid = base.id_generator(5)

        self.screen_rotation = None

        # inherts from atx-uiautomator
        self.swipe = self._uiauto.swipe
        self.drag = self._uiauto.drag
        self.press = self._uiauto.press
        self.long_click = self._uiauto.long_click
        self.dump = self._uiauto.dump_hierarchy