问题

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产生的问题。

解决方法:

  1. 将adb.exe 复制一份到uiautomatorviewer.bat 目录下
  2. 修改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'
}
  • 1
  • 2
  • 3

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("不是文本输入框架,无法删除文字");
} }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

4. 点击输入法键盘的回车搜索

方法1: 切换输入法

利用adb命令先切换为自己的输入法,按了搜索再切换为appium的输入法

查看当前手机的输入法

cmd执行下面的的代码

adb shell ime list -s

可以看到类似下面的结果,

C:\Users\LITP>adb shell ime list -s
com.baidu.input_mi/.ImeService
com.sohu.inputmethod.sogou.xiaomi/.SogouIME
io.appium.android.ime/.UnicodeIME C:\Users\LITP>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

执行adb命令

先写好一个执行cmd的方法

    /**
* 执行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

在需要搜索的时候执行下面的代码,切换的输入法用自己查看列表的输入法内容,我这里是搜狗输入法

        //使用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的一些坑问题错误解决 与 技巧集锦的更多相关文章

  1. [Android测试] Appium的一些坑问题错误解决 与 技巧集锦

    转:https://blog.csdn.net/niubitianping/article/details/52624417 1. error: Failed to start an Appium s ...

  2. RuntimeError: Python is not installed as a framework 错误解决办法

    因为我是macbook,mac是自带的python 2.7,但是我开发需要使用到的是python3,所以先使用pip3 install matplotlib 然后在交互页面键入import matpl ...

  3. 【python】logging日志模块写入中文编码错误解决办法

    一.问题: 使用python的logging模块记录日志,有时会遇到中文编码问题错误. 二.解决办法: 在logging.FileHandler(path) 中添加指定编码方式 encoding='u ...

  4. 关于python安装一些包时出现的错误解决方法

    1.关于wordcloud的安装 --win10,py3.6环境下安装总是出现安装错误,解决方法,下载wordcloud的wheel文件,进行安装. 详情参考:https://github.com/a ...

  5. Python出现"Non-ASCII character '\xe6' in file"错误解决方法

    就没有问题,所以我猜测应该是编码的问题,在网上查了下答案,在第一行加上这样一句话: # encoding: utf-8 将编码格式改变为utf-8问题就解决了!

  6. Python + Robotframework + Appium 之APP自动化测试小试牛刀(Android)

    Robotframework如何好?这里先不说了~ Python更不用说了~ Appium前面的文章有介绍~ 今天直接来Python+Robotframework+Appium 三者结合起来,对And ...

  7. Appium使用Python运行appium测试的实例

    Appium使用Python运行appium测试的实例 一.  Appium之介绍 https://testerhome.com/topics/8038 详情参考--https://testerhom ...

  8. 基于Python的Appium环境搭建合集

    自动化一直是测试圈中的热聊,也是大家追求的技术方向.在测试中,往往回归测试也是测试人员的“痛点”.对于迭代慢.变更少的功能,就能用上自动化来替代人工回归,减轻工作量. 问题 在分享环境搭建之前,先抛出 ...

  9. 转载:appium踩过的坑

    原文地址:http://blog.csdn.net/wirelessqa/article/details/29188665 自己的操作:由于在window上安装appium时,报各种错误:所以选择在u ...

随机推荐

  1. 定时器&改变定时器的执行频率

    static System.Threading.Timer timer; static void Main(string[] args) { Console.WriteLine("Press ...

  2. PhoenixFD插件流体模拟——UI布局【Interaction】详解

    流体交互 本文主要讲解Interaction折叠栏中的内容.原文地址:https://docs.chaosgroup.com/display/PHX3MAX/Liquid+Interaction 主要 ...

  3. 《Http权威指南》读书笔记

    第7章 Http缓存 1.什么是Http缓存? http缓存指的是: 当客户端向服务器请求资源时,会先抵达浏览器缓存,如果浏览器有"要请求资源"的副本,就可以直接从浏览器缓存中提取 ...

  4. php 积分抽奖活动(大转盘)

    以下是项目代码(公众号,使用积分进行抽奖活动),只可做参考: public function Sncode(){ $tid = I('request.tid', 0, 'intval'); // 大转 ...

  5. django xadmin多对多字段过滤(含filter的反向查询)

    要实现的功能: 继昨天实现拓展User模型使其得到其上级用户,今天要实现某些模型与用户多对多字段过滤功能. 功能描述:以用户指派功能为例,当前用户将文件指派给多个下级,修改前 程序会将所有用户都显示出 ...

  6. Bootstrap+PHP表单验证实例

    简单实用的Bootstrap+PHP表单验证实例,非常适合初学者及js不熟悉者,还有ajax远程验证 js验证表单 1 $(document).ready(function() { 2 $('#def ...

  7. 分别用for、while和do-while循环语句以及递归方法计算n!,并输出算式

    一.用for循环实现 实验过程: 实验结果: 二.用while循环实现 实验结果: 三.用do while循环实现 实验结果: 四.用递归算法实现 实验结果: 实验心得: 此次实验中必须熟悉for循环 ...

  8. MySql 游标定义时使用临时表

    参考:Re: Temp Table in Select of a Cursor 方法一: delimiter $$ create procedure test_temp() begin drop te ...

  9. redhat 7 dns 配置

    dns 配置(安装环境是neokylin7.4) #后为需要在root权限下执行的命令 一.安装 修改配置文件1.需要安装的包 bind . bind-chroot .bind-utils #yum ...

  10. 分析easyswoole3.0源码,服务启动为例(一)

    swoole已经升级到4了,主要的特性是更好的支持协程,easyswoole也为了更好支持协程推出了es3.我本地环境是php7.2.9 centos7 在github下载最新的3.0的demo.地址 ...