問題1,運行的時候報錯:
Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error:
'Command 'D:\\android-sdk-windows\\platform-tools\\adb.exe -P 5037 -s b3b50f25 shell ime enable io.appium.settings/.UnicodeIME' exited with code 137'; Stderr: ''; C
ode: '137'
解決辦法:
注釋掉連接手機中的這兩項:
'unicodeKeyboard': True,
'resetKeyBoard': True
問題2:
ERROR root:base_driver.py:61>> Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command 'D:\\android-sdk-windows\\platform-tools\\adb.exe -P 5037 -s b3b50f25 shell pm install -r /data/local/tmp/appium_cache/0cc1725a60a05dbb5d0d09256f2fc6ece7e3b10f.apk' exited with code 1'; Stderr: 'Failure [-99]'; Code: '1'
這個問題應該是adb安裝appium服務的時候報錯了,重新卸載安裝就可以:
# 卸載APP,后面的路徑是報錯的提示中的路徑
adb uninstall /data/local/tmp/appium_cache/0cc1725a60a05dbb5d0d09256f2fc6ece7e3b10f.apk
然后重新安裝,把錯報的那句指令執行一下,提示成功即可,要注意OPPO手機安裝的時候可能提示輸入密碼,手動輸入一下:
adb -P 5037 -s b3b50f25 shell pm install -r /data/local/tmp/appium_cache/0cc1725a60a05dbb5d0d09256f2fc6ece7e3b10f.apk
問題3:
還有一個問題始終沒有解決掉,也是OPPO手機,find toast的時候總是找不到提示信息,使用華為手機就好好的,換OPPO就總找不到,toast顯示的時間挺長的,肯定不是一閃而過不容易獲取到的那種,如果有人能解決,就感激不盡了。
下面是我的find_toast()方法:
def find_toast(self, message, screen_name="", is_screenshot=True, timeout=10.0, time=0.5): """ 獲取toast的內容並返回 :param message: 預期要獲取到的toast部分提示信息 :param screen_name:保存截圖的名字 :param is_screenshot:是否截圖 :param timeout:WebDriverWait尋找toast的超時時間 :param time:每隔多長時間尋找toast一次 :return: 返回找到的toast提示信息 """ message = "text," + message try: element = self.find_element((By.XPATH, message), timeout, time) if is_screenshot: self.screenshot(screen_name) except Exception: logger.error("沒有找到這句提示信息:%s" % message[5:]) return False return element.text