首先定义好driver
desired_caps = {}
desired_caps[‘platformName’] = ‘Android’
desired_caps[‘deviceName’] = device
driver = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub’, desired_caps)
driver.implicitly_wait(20)
重启设备并等待设备启动后执行元素查找
os.popen(“adb reboot”)
WebDriverWait(driver, time).until(lambda x: x.find_element(by, value))
报错
Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: ‘POST /element’ cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details