標籤:simple RoCE cat input ras for sdn 底部 size
感謝這位朋友的總:52624417,轉起問題1. error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
之前的會話沒有關閉,然後你又運行了測試執行個體,也沒有設定覆蓋.
解決:
1. 重新停止appium服務,開啟Appium服務
2. 在Genarel Setting那裡設定覆蓋Session,重啟Appium
測試結束在AfterClass加driver.quit()
2. error: Failed to start an Appium session, err was: Error: Command failed: C:\Windows\system32\cmd.exe /s /c “D:\android-sdk-windows\platform-tools\adb.exe -s adb server version (32) doesn’t match this client (36); killing…
wait-for-device”
error: could not install smartsocket listener: cannot bind to 127.0.0.1:5037:
沒有連結上手機或者模擬器,請確認已經串連成功,重新連結
3. error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.
手機系統低於4.2,appium不支援4.2.2以下的系統,請換一個手機或者模擬器來測試。
4. Error: Permission to start activity denied.
**activity在資訊清單檔裡面沒添加android:exported=”true”的話,你不能直接開啟對應的activity,需要從啟動頁activity開啟。
exported屬性就是設定是否允許activity被其它程式調用**
5. error: Failed to start an Appium session, err was: Error: Activity used to start app doesn’t exist or cannot ve launched! Make usre it exists and is launchable activity
要開啟的activity不存在,activity路徑錯誤,改為完整正確的activity路徑
6. error: Failed to start an Appium session, err was: Error: ‘java - version’ failed. Error: Command failed: C:\Windows\system32\cmd.exe /s /c “java -version”
Java版本錯誤,請安裝最新的版本。
7.> info: [debug] Error: Command failed: C:\Windows\system32\cmd.exe /s /c “D:\android-sdk-windows\platform-tools\adb.exe -s 8806a0b0 shell “echo ‘ready‘“error: unknown host service
連結手機失敗,重新連結手機即可,我就是重新拔插了一下usb
Error: Command failed: C:\Windows\system32\cmd.exe /s /c “D:\android-sdk-windows\platform-tools\adb.exe -s 8806a0b0 shell “echo ‘ping’”“
error: unknown host service
adb被突然佔用導致,例如你在運行用例的時候運行了模擬器。
7. UIAutomatorViewer提示: Unable to connect to adb. Check if adb is installed correctly
解決,sdk升級到了25產生的問題。
解決方案:
- 將adb.exe 複製一份到uiautomatorviewer.bat 目錄下
- 修改uiautomatorviewer.bat檔案最後一行(改binddir=%prog_dir%為自己的platform-tools本地路徑)
技巧
1. 每次測試都重新安裝app
為capabilities色設定noReset為true
capabilities.setCapability(“noReset”, true);
2. 中文亂碼
這都是編碼問題:
1.方法1:
Android Studio修改檔案編碼的方法,最底部的UTf-8,點擊選GBK就可以了,reload檔案。(ps: 先把檔案內容全選複製一下再轉換編碼,再粘貼,不然檔案內容就變亂碼了)
2.方法2:
用的是原來的UTF-8編碼,然後在測試module的build.gradle裡面添加三行代碼
tasks.withType(JavaCompile){ options.encoding = ‘UTF-8‘}
3. 清除編輯框EditText內容
這個問題好像是看手機系統的,我之前的手機就會出現sendKeys的時候沒有全選去掉本來的內容,現在都會自動全選覆蓋了,這個也不算問題了。
/** * 逐字刪除編輯框中的文字 * @param element 文字框架控制項 */ public void clearText(AndroidElement element){ String className = element.getClass().getSimpleName(); if (className.equals("EditText")){ String text = element.getText(); //跳到最後 driver.pressKeyCode(KEYCODE_MOVE_END); for (int i = 0; i < text.length(); i ++){ //迴圈後退刪除 driver.pressKeyCode(BACKSPACE); } }else { print("不是文本輸入架構,無法刪除文字"); } }
4. 點擊IME鍵盤的斷行符號搜尋
方法1: 切換IME
利用adb命令先切換為自己的IME,按了搜尋再切換為appium的IME
查看當前手機的IME
cmd執行下面的的代碼
adb shell ime list -s
可以看到類似下面的結果,
C:\Users\LITP>adb shell ime list -scom.baidu.input_mi/.ImeServicecom.sohu.inputmethod.sogou.xiaomi/.SogouIMEio.appium.android.ime/.UnicodeIME
執行adb命令
先寫好一個執行cmd的方法
/** * 執行adb命令 * @param s 要執行的命令 */ private void excuteAdbShell(String s) { Runtime runtime=Runtime.getRuntime(); try{ runtime.exec(s); }catch(Exception e){ print("執行命令:"+s+"出錯"); } }
在需要搜尋的時候執行下面的代碼,切換的IME用自己查看列表的IME內容,我這裡是搜狗IME
//使用adb shell 切換IME-更改為搜狗拼音,這個看你本來用的什麼IME excuteAdbShell("adb shell ime set com.sohu.inputmethod.sogou.xiaomi/.SogouIME"); //再次點擊輸入框,調取鍵盤,軟鍵盤被成功調出 clickView(page.getSearch()); //點擊右下角的搜尋,即ENTER鍵 pressKeyCode(AndroidKeyCode.ENTER); //再次切回 IME鍵盤為Appium unicodeKeyboard excuteAdbShell("adb shell ime set io.appium.android.ime/.UnicodeIME");
[Android測試] Appium的一些坑問題錯誤解決 與 技巧集錦