appium踩坑填坑实录

1. 

问题:

price_st1 = price_str.split('¥')————————>这个的返回值是["","199.00"]

报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)
reload(sys)
sys.setdefaultencoding('utf-8')

price_str = '¥199.00'

解决方案:

在头文件添加

import sys

2.

问题:
层级结构:
FrameLayout
       textview1
       textview2
关系描述:
FrameLayout是textview1和textview2的父布局,通过FrameLayout定位textview1和textview2
点击FrameLayout跳页,用textview1和textview2判断FrameLayout的唯一性,防止重复点击
问题描述:
当FrameLayout显示不完全的时候,可以点击FrameLayout跳页,但是这时候是不能通过FrameLayout定位到textview1和textview2的,如果获取不到textview1和textview2就会报错
解决方案:
(思路:使用try代码去定位textview1和textview2,定位到textview1和textview2才去点击FrameLayout)
try:
    textview=通过FrameLayout定位textview1和textview2
    return textview
except:
    textview=None
    return textview
if  textview:
    FrameLayout.click()

3.

python中的for函数:
for  i  in ~~~:
~~~为序列,不能用int值,但是可以用range(start,stop,step)函数
python中的range函数:
range(start,stop,step)————————>[start,sop)
例如:range(0,8,2)————————>0,2,4,6

4.

问题:

self.driver.swipe(x, y, x, y1,)函数每次滑动之后停止的位置都不一样。
解决方案:
self.driver.swipe(x, y, x, y1, 5000)——————>添加一个滑动执行时间

5.

问题:

在Android原生的模拟器上安装Android的apk的时候遇到这样的错误提示:

The APK failed to install.

Error:INSTALL_FALLED_NO_MATCHING_ABIS

错误的原因是:

在项目中使用了native libraries,而当前的cpu体系结构不支持该native libraries。

现在安卓模拟器的cpu/ABI一般有三种类型,INTEL X86,ARM,MIPS

解决方案:

电脑支持的话就换模拟器的cpu/ABI,不支持的话选择其他的模拟器例如:夜神、海马玩、genymotion,行不通的话就选root的真机吧,坑少。

6.

问题:
使用海马玩模拟器的时候adb识别不出该模拟器
解决方案:执行命令:adb connect 127.0.0.1:26944。
备注:

海马玩的端口号是:26944

夜神端口号是:62001

7.

问题:

真机运行adb devices命令的时候出现如下错误:adb server version (31) doesn't match this client (36); killing...

List of devices attached

adb server version (31) doesn't match this client (39); killing...
error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (10048)
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon
而且这个error一会儿出现一会儿又没有,但是使用adb命令安装应用的时候一直显示waiting for device

问题原因:

socket 的端口被占用了

解决方案:

很多手机助手会占用这个端口,选择把手机助手退出或者卸载,就能正常使用adb命令安装应用了

8.

问题:

启动工具uiautomatorviewer,点击第二个按钮Device Screenshot时,出现Unable to connect to adb. Check if adb is installed correctly错误: 

解决办法:

打开uiautomatorviewer.bat,找到uiautomatorviewer.bat文件最后一行

call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=%prog_dir%" -jar %jarpath% %*

将其中的binddir=%prog_dir%修改为SDK的platform-tools所在路径。

修改后的最后一行为:

call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=你的platform-tools地址" -jar %jarpath% %*

再次启动工具uiautomatorviewer。

待续。。。







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值