[Android Test] Appium Some pit problems error solving and skill collection

Source: Internet
Author: User
Tags appium

Thanks to this friend's total: 52624417, turn up question 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:

    1. Copy the Adb.exe to the Uiautomatorviewer.bat directory
    2. 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.

    /**     * 逐字删除编辑框中的文字     * @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. 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/.UnicodeIME
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+"出错"); } }

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");

[Android Test] Appium Some pit problems error solving and skill collection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.