python+appium自动化测试遇到的一些坑及问题总结(二)

Issue 11: selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: Requested a new session but one was in progress)

Solution:
停止再启动Appium

Issue 12: 2个文件一起执行时,第二个文件报错:AttributeError: ‘NoneType’ object has no attribute ‘getDriver’

cls.driver = appium_config.DriverClient().getDriver()
AttributeError: ‘NoneType’ object has no attribute ‘getDriver’

Solution:
暂时还没有解决方法。

Issue 13: AttributeError: ‘Job’ object has no attribute ‘assertEqual’

Solution:
https://stackoverflow.com/questions/42859577/object-has-no-attribute-assertequal

assertEqual is a method that belongs to the class TestCase from the unittest module (python unittest docs).
The reason it works in your test code is most likely because you test class inherits from the TestCase class.
class YourTestClass(unittest.TestCase):
pass
You could just use the keyword assert:
assert “IRELAND INSTITUTE OF PITTSBURGH” == driver.find_element_by_id(“cname”).get_attribute(“value”)
If the assertion fails, it will raise an AssertionError.

Issue 14: 安装appium-desktop或appiumForWindows,执行的现象不一样

现象:
家:
a. 每次都要安装io.appium.automatorUI2.server, 需要手动点安装
solution: Appium: appium-desktop-1.15.1, 升级成最新版本appium-desktop-1.18.0

b. 每次打开APP,开屏页都要点“跳过”“下一步”“下一步”、、、
c. NA
d. 验证码输入,一起输验证码数字,才不会报错

公司:
a. NA
b. NA
c. 启动APP时设置的 desired_caps[‘unicodeKeyboard’] = ‘true’, 要报错,需要注释掉,再在手机设置手动改成appium的输入法 —appium版本问题
d. 验证码输入,一个字一个字地输入,才不会报错

软件版本:
家:
Appium: appium-desktop-1.15.1 (new)

公司:
Appium: AppiumForWindows_1_4_16_1 (old)

Appium-server(AppiumForWindows)和appium-desktop有什么区别和关系?
Appium的不同版本有不同的叫法,以2015 年底为界限,之前叫Appium-Server(即1/2/3篇中使用的appium) ,之后叫 Appium-desktop ,当然, Appium-Server当前仍然是可用的。
Appium-Server <----------------- 2015 年底 -----------------> Appium-desktop
AppiumForWindows_1_4_16_1.zip 是Windows版在 2015 年底止步的Appium-Server !!

Issue 15: 真机运行没问题, 夜神模拟器报错:Parameters were incorrect. We wanted {“required”:[“value”]} and you sent [“text”,“value”,“id”,“sessionId”

Solution:
https://blog.csdn.net/Chenftli/article/details/88179905
Appium log:
[HTTP] --> POST /wd/hub/session/c36c7643-e3e1-44fc-afce-41577d54051c/element/2/value {“text”:“18782913789”,“value”:[“1”,“8”,“7”,“8”,“2”,“9”,“1”,“3”,“7”,“8”,“9”],“id”:“2”,“sessionId”:“c36c7643-e3e1-44fc-afce-41577d54051c”}
这是由于版本webdriver版本和appium的版本对不上所致。
先确定你webdriver用的是selenium中的还是Appium-python-client中的.
1.如果你用的是selenium,appium使用的是1.5版本的,则将selenium卸载,下载selenium版本3.3的
比如:卸载:pip uninstall selenium 安装:pip install selenium3.3.1
2.如果是Appium-python-client,下面是与appium对应的版本
Appium-python-client 中0.32-0.39对应的是appium版本
Appium-python-client 中0.22-0.31对应的是appium1.5版本
Appium-python-client中0.14对应是appium1.3.6版本
Appium-python-client中0.15-0.21对应是appium1.4版本
比如:我安装的是appium1.5,所以我用了 pip install Appium-Python-Client
0.25

Issue 16: 报错:ImportError: cannot import name ‘InvalidArgumentException’

https://blog.csdn.net/Chenftli/article/details/88184802

issue 17: selenium.common.exceptions.WebDriverException: Message: A new session could not be created. (Original error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c ““C:\Program Files (x86)\SDK\android-sdk-windows\platform-tools\adb.exe” -s 127.0.0.1:62026 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””

解决办法:
Solution 1:
adb命令卸载:
adb uninstall io.appium.settings
adb uninstall io.appium.unlock

Solution 2:
在真机/模拟器上手动卸载appium settings和unlock

Solution 3:
写脚本删除,并加上自动化测试的teardown里面
def uninstall_settings(self):
adb_settings = “adb uninstall io.appium.settings”
os.system(adb_settings)

def uninstall_unlock(self):
    adb_unlock = "adb uninstall io.appium.unlock"
    os.system(adb_unlock)

issue 18: 安装并打开appium提示NET Framework初始化错误

在这里插入图片描述
Solution:
下载并安装.NET Framework 4
下载链接:
https://www.microsoft.com/zh-cn/download/details.aspx?id=17718
在这里插入图片描述

Issue 19: 元素有resource-id,用id和xpath都无法定位

https://testerhome.com/topics/13078
https://blog.csdn.net/a10703060237/article/details/107729727
Solution:
1.用坐标定位
2.用class定位
driver.find_element_by_android_uiautomator('new UiSelector().className(“android.widget.TextView”).text(“销售经理”).click()

Issue 20: 用appium error: Unhandled error: TypeError: undefined is not a function

Solution:
AppiumforWindows报的错,换成appium-desktop就OK了

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值