Appium踩坑总结--解决方法

目录:
一、电脑存在appium命令版以及appium-desktop版本
二、华为手机手动卸载appium settings和uiautomator2软件后,再次运行脚本报错
三、IOS手机元素定位
四、滑动页面查找到指定的元素并点击
五、利用self.driver.start_activity方法调用app时appium报错:<-- POST /wd/hub/session/545435435-b6fc-400b-b4e0-54554/appium/device/start_activity 500

一、电脑存在appium命令版以及appium-desktop版本

开启appium-desktop版本后执行脚本报错:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the ‘com.xxxx’ application.
主要意思:处理命令时发生未知服务器端错误

检查:
我这边查看到命令行版本(1.20.2)与桌面版本(1.14.1)不一致,appium -v,查看版本
在这里插入图片描述

解决方法:
关闭桌面版本,cmd中输入appium执行命令行版本,执行脚本,可成功运行
解决2:升级桌面appium版本或者降低appium命令行版本

二、华为手机手动卸载appium settings和uiautomator2软件后,再次运行脚本报错

报错内容:
DEPRECATION WARNING:
[Appium]
[Appium] The ‘automationName’ capability was not provided in the desired
[Appium] capabilities for this Android session
[Appium]
[Appium] Setting ‘automationName=UiAutomator2’ by default and using the
[Appium] UiAutomator2 Driver
[Appium]
[Appium] The next major version of Appium (2.x) will require the
[Appium] ‘automationName’ capability to be set for all sessions on all
[Appium] platforms
[Appium]
[Appium] In previous versions (Appium <= 1.13.x), the default was
[Appium] ‘automationName=UiAutomator1’
[Appium]
[Appium] If you wish to use that automation instead of UiAutomator2, please
[Appium] add ‘automationName=UiAutomator1’ to your desired capabilities
[Appium]
[Appium] For more information about drivers, please visit
[Appium] http://appium.io/docs/en/about-appium/intro/ and explore the
[Appium] ‘Drivers’ menu
在这里插入图片描述
原因:手动卸载软件没有卸载干净,无法继续安装程序
解决:adb命令卸载,卸载两个软件:
adb uninstall io.appium.settings
adb uninstall io.appium.uiautomator2.server

三、IOS手机元素定位

注意当visible为false时,表示元素不可见,定位时可能会定位不到,一般当visible为false不建议使用这个元素来做操作
在这里插入图片描述

四、滑动页面查找到指定的元素并点击

        i = 1
        while i < 6:
            try:
                driver.find_element_by_accessibility_id("Summer Dress >").click()  # 尝试点击元素
                break
            except Exception as e:
            #longPress()多了一个入参duration,因为需要长按,所以须有一个按的时间。它以毫秒为单位。1000表示按一秒钟。
                TouchAction(driver).long_press(x=194, y=728, duration=1000).move_to(x=193, y=300).release().perform()  # 长按滑动屏幕
                i = i + 1

五、Android启动指定activity时报错 <-- POST /wd/hub/session/545435435-b6fc-400b-b4e0-54554/appium/device/start_activity 500

原因:发现appium桌面版本为1.12.1,命令行版本为1.20.2,估计低版本不支持self.driver.start_activity()方法
解决方法:升级桌面版本,,或者利用高版本的命令行来启动

### 回答1: appium-python-client安装包可以通过pip命令进行安装,具体步骤如下: 1. 打开命令行工具(如Windows下的cmd或者Linux下的终端),输入以下命令安装pip: ``` sudo apt-get install python-pip ``` 2. 安装appium-python-client,输入以下命令: ``` pip install Appium-Python-Client ``` 3. 等待安装完成即可使用appium-python-client。 ### 回答2: appium-python-client是一个用于进行移动应用测试的Python库。它作为Appium测试框架的一个客户端,提供了许多功能和方法来编写和执行测试脚本。 要安装appium-python-client,需要先确保已经安装了Python环境。以下是安装appium-python-client的步骤: 1. 打开终端或命令提示符,并进入到所需的Python项目目录。 2. 使用pip命令安装appium-python-client。在终端或命令提示符输入以下命令: pip install Appium-Python-Client 在执行命令后,pip会从Python Package Index(PyPI)上下载并安装appium-python-client。 安装完成后,您可以在Python脚本导入appium-python-client并开始编写测试代码。 例如,您可以使用以下命令导入appium-python-client库: ```python from appium import webdriver ``` 然后,您可以使用appium-python-client提供的方法启动Appium服务器、初始化移动设备连接、定位元素,并执行各种移动应用测试操作。 总结appium-python-client是一个用于进行移动应用测试的Python库,可以通过pip命令进行安装。安装完成后,您可以在Python脚本导入该库并使用其提供的方法来编写和执行移动应用测试脚本。 ### 回答3: appium-python-client是一个用于与Appium服务器进行通信的Python库。要安装appium-python-client,您可以按照以下步骤进行操作: 1. 确保您的电脑已经安装了Python解释器。您可以通过在命令行输入“python --version”来验证Python是否已经安装。 2. 打开命令行或终端,并输入以下命令来安装appium-python-client: ``` pip install Appium-Python-Client ``` 注意:您需要确保您的电脑已经安装了pip,它是一个用于安装Python库的包管理工具。如果您的电脑上没有安装pip,您可以通过以下命令来安装它: ``` python -m ensurepip --upgrade ``` 3. 安装完成后,您可以在Python脚本导入appium-python-client模块并使用它来与Appium服务器进行通信。例如,您可以使用以下代码示例来连接到Appium服务器: ```python from appium import webdriver desired_caps = { 'platformName': 'Android', 'platformVersion': '9', 'deviceName': 'Android Emulator', 'app': 'path/to/your/app.apk' } driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) ``` 这将创建一个WebDriver实例,用于控制连接到Appium服务器的设备。您可以使用WebDriver实例来执行各种测试操作,例如查找元素、发送输入等。 通过按照以上步骤安装appium-python-client,您就可以在Python使用它来创建和执行Appium测试。
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值