1. app在手機上打開,鏈接電腦。html
2. 在chrome瀏覽器中輸入chrome://inspectweb
3. 在Remote Target中 出現app的webview內容,說明鏈接成功chrome
4. 點擊Inspect能夠遠程調試瀏覽器
=========================================================================================app
記住是webview須要,因此要下webview須要的chromedriver的版本,不要下pc端的chrome瀏覽器對應的chromedriver版本。ide
不然會報錯:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: No Chromedrivers found in 'D:\ChromeDriver\chromedriver_75.exe'測試
1. 代碼中,只要加上一條:spa
desired_caps['chromedriverExecutableDir'] = r'D:\ChromeDriver\chromedriver_win32_2.34\chromedriver.exe'
2. Appium中:調試
無論哪一種方法,路徑後都須要到xxx.exe才能夠,不然報錯會報找不到。code
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Trying to use a chromedriver binary at the path D:\ChromeDriver\chromedriver_win32_2.34\chromedriver, but it doesn't exist!
3. 代碼
1 #切換到webview 2 print(driver.contexts) 3 print(driver.current_context) 4 driver.switch_to.context("WEBVIEW_com.example.jcy.wvtest") 5 #輸入你好,點擊搜索 6 driver.find_element_by_id("index-kw").send_keys("你好") 7 time.sleep(2) 8 driver.find_element_by_id("index-bn").click() 9 #切換到app 10 driver.switch_to.context("NATIVE_APP") 11 #點擊通知 12 driver.find_element_by_xpath("//*[@content-desc='通知']").click()