problem
1. error:failed to start an Appium session, Err was:Error:Requested a new session but one is in progress
The previous session was not closed, and then you ran the test instance and did not set the overwrite.
Solve:
1. Re-stop the Appium service and turn on the Appium service
2. Set cover session in Genarel setting, restart Appium
End of Test at Afterclass plus Driver.quit ()
2. error:failed to start an Appium session, err Was:Error:Command failed:c:\windows\system32\cmd.exe/s/C "D:\and roid-sdk-windows\platform-tools\adb.exe-s ADB Server version (+) doesn ' t match this client (36); Killing ...
Wait-for-device "
Error:could not install smartsocket listener:cannot bind to 127.0.0.1:5037:
No link on the phone or simulator, please confirm the connection is successful, relink
3. Error:android devices must be of the API level or higher. Your device to selendroid or upgrade Android on your device.
Mobile phone system less than 4.2,appium does not support 4.2.2 below the system, please change a phone or simulator to test.
4. Error:permission to start activity denied.
**activity in the manifest file does not add android:exported= "true", you can not directly open the corresponding activity, need to open from the Start page activity.
The exported property is the setting whether activity is allowed to be called by other programs * *
5. error:failed to start a Appium session, err Was:Error:Activity used to start app doesn ' t exist or cannot ve Lau nched! Make usre it exists and is launchable activity
The activity path is not present, and it is changed to the complete correct activity path.
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 version error, please install the latest version .
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
Link phone failed, relink the phone, I just reseated a bit of 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
The ADB is caused by a sudden seizure, such as when you run the emulator while running the use case.
7. Uiautomatorviewer Hint: Unable to connect to ADB. Check if ADB is installed correctly
Resolved, the SDK has been upgraded to 25 issues.
Workaround:
- Copy the Adb.exe to the Uiautomatorviewer.bat directory
- Modify the last line of the Uiautomatorviewer.bat file (change binddir=%prog_dir% to its own platform-tools local path)
Tips
1. Reinstall the app for each test
Set NoReset to true for capabilities color
Capabilities.setcapability ("NoReset", true);
2. Chinese garbled
This is all a coding problem:
1. Method 1:
Android Studio Modified file encoding method, at the bottom of the UTf-8, click on select GBK on it, reload file. (PS: The file contents of the first copy of the full selection and then convert the code, and then paste, or the contents of the file will become garbled)
2. Method 2:
Use the original UTF-8 code, and then add three lines of code to the Build.gradle of the test module
tasks.withType(JavaCompile){ options.encoding = ‘UTF-8‘}
3. Clear the Edit box edittext content
This problem seems to be looking at the mobile phone system, my previous phone will appear sendkeys when there is no choice to remove the original content, now will automatically select all covered, this is not a problem.
/** * Verbatim deletion of text in the edit box *< Span class= "Hljs-javadoctag" > @param element text frame control */public void cleartext (androidelement Element) {String className = Element.getclass (). Getsimplename (); if (classname.equals ( "EditText")) {string text = Element.gettext (); //jumps to the last Driver.presskeycode (Keycode_move_end); for (int i = 0; i < text.length (); i + +) {//Loop back Delete driver.presskeycode (BACKSPACE);}} else {print ( "not text input frame, cannot delete text");}}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
4. Click the input keyboard to enter search
Method 1: Switch the IME
Use the ADB command to switch to its own input method, press the search and then switch to the Appium input method
view input methods for the current phone
CMD executes the following code
ADB Shell IME list-s
You can see results similar to the following,
C:\Users\LITP>adb shell ime list -scom.baidu.input_mi/.ImeServicecom.sohu.inputmethod.sogou.xiaomi/.SogouIMEio.appium.android.ime/.UnicodeIMEC:\Users\LITP>
execute adb command
Write a method to execute CMD first
/** * 执行adb命令 * @param s 要执行的命令 */ private void excuteAdbShell(String s) { Runtime runtime=Runtime.getRuntime(); try{ runtime.exec(s); }catch(Exception e){ print("执行命令:"+s+"出错"); } }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
In the need to search the time to execute the following code, switch the input method with its own view list of input method content, I here is Sogou Input method
//使用adb shell 切换输入法-更改为搜狗拼音,这个看你本来用的什么输入法 excuteAdbShell("adb shell ime set com.sohu.inputmethod.sogou.xiaomi/.SogouIME"); //再次点击输入框,调取键盘,软键盘被成功调出 clickView(page.getSearch()); //点击右下角的搜索,即ENTER键 pressKeyCode(AndroidKeyCode.ENTER); //再次切回 输入法键盘为Appium unicodeKeyboard excuteAdbShell("adb shell ime set io.appium.android.ime/.UnicodeIME");
转自:http://blog.csdn.net/niubitianping/article/details/52624417
"Python-appium" Appium some pit problems error solving and skill collection