class TestBrowser(): def setup(self): des_caps = { 'platformName':'Android', 'platformVersion':'7.1.2', 'browserName':'Chrome', 'noReset':True, 'deviceName':'127.0.0.1:11509', 'chromedriverExecutable':'D:/app_chromedriver/chromedriver_win32/chromedriver.exe' } self.driver = webdriver.Remote("http://localhost:4723/wd/hub",des_caps) self.driver.implicitly_wait(10) def teardown(self): self.driver.quit() def test_browser(self): self.driver.get("https://m.baidu.com") sleep(5) self.driver.find_element(By.ID,"index-kw").click() self.driver.find_element(By.ID,"index-kw").send_keys("appium") search_locator = (By.ID,"index-bn") WebDriverWait(self.driver,10).until(expected_conditions.visibility_of_element_located(search_locator)) self.driver.find_element(*search_locator).click() ---------------------------------------------------- 异常报错的情况: # sending a valid response. > raise RemoteDisconnected("Remote end closed connection without" " response") E urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) D:\Python3.8\lib\http\client.py:272: ProtocolError F test_browser.py:28 (TestBrowser.test_browser) self = method = 'POST' url = '/wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/element' body = '{"using": "id", "value": "index-kw"}' headers = {'Accept': 'application/json', 'Connection': 'keep-alive', 'Content-Type': 'application/json;charset=UTF-8', 'User-Agent': 'appium/python 2.8.1 (selenium/4.8.2 (python windows))'} retries = Retry(total=3, connect=None, read=None, redirect=None, status=None) redirect = False, assert_same_host = False timeout = , pool_timeout = None release_conn = True, chunked = False, body_pos = None response_kw = {'request_url': 'http://localhost:4723/wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/element'} parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/element', query=None, fragment=None) destination_scheme = None, conn = None, release_this_conn = True http_tunnel_required = False, err = None, clean_exit = False --------------------------------------------------------- [HTTP] [HTTP] --> POST /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/timeouts [HTTP] {"implicit":10000} [W3C (8c821f17)] Driver proxy active, passing request on via HTTP proxy [WD Proxy] Matched '/wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/timeouts' to command name 'timeouts' [Protocol Converter] Will send the following request bodies to /timeouts: [{"type":"implicit","ms":10000}] [WD Proxy] Proxying [POST /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/timeouts] to [POST http://127.0.0.1:8000/wd/hub/session/7c15751774eac3f706eeabeb24d55639/timeouts] with body: {"type":"implicit","ms":10000} [WD Proxy] Got response with status 200: {"sessionId":"7c15751774eac3f706eeabeb24d55639","status":0,"value":null} [WD Proxy] Replacing sessionId 7c15751774eac3f706eeabeb24d55639 with 8c821f17-9f91-4042-9484-e9dcb60f6998 [HTTP] <-- POST /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/timeouts 200 9 ms - 65 [HTTP] [HTTP] --> POST /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/url [HTTP] {"url":"https://m.baidu.com"} [W3C (8c821f17)] Driver proxy active, passing request on via HTTP proxy [WD Proxy] Matched '/wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/url' to command name 'setUrl' [WD Proxy] Proxying [POST /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/url] to [POST http://127.0.0.1:8000/wd/hub/session/7c15751774eac3f706eeabeb24d55639/url] with body: {"url":"https://m.baidu.com"} [WD Proxy] Got response with status 200: {"sessionId":"7c15751774eac3f706eeabeb24d55639","status":0,"value":null} [WD Proxy] Replacing sessionId 7c15751774eac3f706eeabeb24d55639 with 8c821f17-9f91-4042-9484-e9dcb60f6998 [HTTP] <-- POST /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998/url 200 1034 ms - 65 [HTTP] [HTTP] --> DELETE /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998 [HTTP] {} [W3C (8c821f17)] Calling AppiumDriver.deleteSession() with args: ["8c821f17-9f91-4042-9484-e9dcb60f6998"] [BaseDriver] Event 'quitSessionRequested' logged at 1681367728527 (14:35:28 GMT+0800 (中国标准时间)) [Appium] Removing session 8c821f17-9f91-4042-9484-e9dcb60f6998 from our master session list [UiAutomator2] Deleting UiAutomator2 session [AndroidDriver] Stopping chromedriver for context CHROMIUM [Chromedriver] Changed state to 'stopping' [WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8000/wd/hub/session/7c15751774eac3f706eeabeb24d55639] with no body [WD Proxy] Got response with status 200: {"sessionId":"7c15751774eac3f706eeabeb24d55639","status":0,"value":null} [Chromedriver] Changed state to 'stopped' [UiAutomator2] Deleting UiAutomator2 server session [WD Proxy] Matched '/' to command name 'deleteSession' [WD Proxy] Proxying [DELETE /] to [DELETE http://localhost:8200/wd/hub/session/ead01ce0-e63d-4794-8316-5fe5c460ac7f] with no body [WD Proxy] Got response with status 200: {"sessionId":"ead01ce0-e63d-4794-8316-5fe5c460ac7f","value":null} [Logcat] Stopping logcat capture [ADB] Removing forwarded port socket connection: 8200 [ADB] Running 'D:\Android_sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:11509 forward --remove tcp\:8200' [BaseDriver] Event 'quitSessionFinished' logged at 1681367728793 (14:35:28 GMT+0800 (中国标准时间)) [W3C (8c821f17)] Received response: null [W3C (8c821f17)] But deleting session, so not returning [W3C (8c821f17)] Responding to client with driver.deleteSession() result: null [HTTP] <-- DELETE /wd/hub/session/8c821f17-9f91-4042-9484-e9dcb60f6998 200 270 ms - 14 [HTTP] [Instrumentation] . [Instrumentation] Time: 18.008 [Instrumentation] [Instrumentation] OK (1 test) [Instrumentation] The process has exited with code 0