appium + webdriver + HTML 经常遇到的问题

目录

问题1:Mac和iOS通信 进行自动化测试参考Desired Capabilities官方说明文档

问题2:driver = webdriver.Remote(“http://localhost:4723/wd/hub“, caps)

问题3:Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

问题4:An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output

问题5:The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

问题6:Encountered internal error running command: Error: Device 127.0.0.1:4723 was not in the list of connected device

问题7:Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up

问题8:Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output

问题9:scrcpy 无线投屏 无法连接

问题10:Mac和iOS通信 进行自动化测试参考Desired Capabilities官方说明文档

问题11:SessionNotCreatedException

问题12:AttributeError: 'XXX' object has no attribute 'endswith' 

问题13:appium 中inspect   (如何切换定位H5   原生APP  混合型APP)  定位

问题14:自动下载更新浏览器驱动可能会遇到问题?



appium 库一定要装 

问题1:Mac和iOS通信 进行自动化测试参考Desired Capabilities官方说明文档

参考如下进行配置:

Desired Capabilities官方说明文档:Desired Capabilities in Selenium Testing With Examples

问题2:driver = webdriver.Remote(“http://localhost:4723/wd/hub“, caps)

An unknown server-side error occurred while processing the command

处理命令时发生未知的服务器端错误

An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.tencent.mobileqq' application

问题出现 appium server  ,修改appium服务器

localhost:4723  改为127.0.0.1:4723

问题3:Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

JavaApp自动化测试系列[v1.0.0][Appium常见问题处理]_appiumservicebuilder does not define or inherit an_Davieyang.D.Y的博客-CSDN博客

问题4:An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output

An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output

处理命令时发生了一个未知的服务器端错误.原始错误:无法初始化检测过程。制作确保测试中的应用程序不会崩溃,并调查logcat输出。

第一步检查手机设备是否正常

adb devives

第二步检查手机上启动脚本时注意手机提示安装appium setting否者连接。调试脚本时需要注意手机动态

第三步检查appium上日志输出

第四步检查app日志输出,命令如下:

adb shell logcat

问题5:The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

找不到请求的资源,或者使用映射资源不支持的 HTTP 方法接收到请求

问题6:Encountered internal error running command: Error: Device 127.0.0.1:4723 was not in the list of connected device

设备断开了,连接配置信息错误,如udid(adb devices获取)

检查是否连接,时时注意手机动态

问题7:Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up

运行如下两句
adb  uninstall io.appium.uiautomator2.server
adb  uninstall io.appium.uiautomator2.server.test

问题8:Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output

Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output
遇到内部错误运行命令:错误:无法初始化检测进程。 确保被测应用程序没有崩溃并调查 logcat 输出

确保如上三个全部安装 

package:io.appium.settings
package:io.appium.uiautomator2.server
package:io.appium.uiautomator2.server.test

确保如上三个全部安装

问题9:scrcpy 无线投屏 无法连接

首先使用USB 数据连接手机和电脑,手机打开开发者模式

使用adb devices  发现如下则没有连接上,请检查 开发者调式功能是否打开 

打开开发调式即可再次输入adb devices 

然后在scrcpy 进行无线投屏 连接操作步骤如下:GitHub - Genymobile/scrcpy 

adb devices
    确定是否连接


adb tcpip 5555
    后面的5555为端口,可以指定其他的端口,前提是端口未被调用

adb connect 192.168.xxxx.xxxx:5555 
    192.168.xxxx.xxxx为你手机的ip地址,5555为了设置·的端口号

adb devices
    检查是否刚才输入192.168.xxxx.xxxx:5555

scrcpy
    输入scrcpy即可投屏

问题10:Mac和iOS通信 进行自动化测试参考Desired Capabilities官方说明文档

参考如下进行配置:

Desired Capabilities官方说明文档:Desired Capabilities in Selenium Testing With Examples

问题11:SessionNotCreatedException

java报错:SessionNotCreatedException: Could not start a new session. Response code 500

System.setProperty("webdriver.chrome.driver",
"D:\\script\\java\\StudentAutoExcel\\DriverExe)

系统环境变量设置了版本对应还是设置脚本设置启动webdriver

需要设置System.setProperty() 路径带上exe     设置 webdriver驱动的路径

python报错:exceptions.SessionNotCreatedException: Message: session not created: This version of xxxdriver 

问题12:AttributeError: 'XXX' object has no attribute 'endswith' 

如下几种报错

        AttributeError: 'int' object has no attribute 'endswith' 

        AttributeError: 'float' object has no attribute 'endswith' 

        AttributeError: 'bool' object has no attribute 'endswith' 

了解endswith使用方法:startswith()  和 endswith()  都对字符处理

解决办法:①检查本身代码脚本是否为 str 字符串

                  ②如调用外部文件如execl,yml,yaml 在代码进行强转操作为 str 字符串

问题13:appium 中inspect   (如何切换定位H5   原生APP  混合型APP)  定位

问题14:自动下载更新浏览器驱动可能会遇到问题?

https://github.com/bonigarcia/webdrivermanager/blob/master/src/doc/asciidoc/index.adoc#http-response-code-403

    public WebDriver createChromeAndroidDriver(String browserVersion,String deviceName, URL appiumServerUrl) {
        // Resolve driver and get its path(解析驱动程序并获取其路径)
        WebDriverManager wdm = WebDriverManager.chromedriver().browserVersion(browserVersion);
        wdm.setup();
        String chromedriverPath = wdm.getDownloadedDriverPath();

        // Create WebDriver instance using the driver path
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", "chrome");
        capabilities.setCapability("version", browserVersion);
        capabilities.setCapability("deviceName", deviceName);
        capabilities.setCapability("platformName", "android");
        capabilities.setCapability("chromedriverExecutable", chromedriverPath);

        return new AndroidDriver<WebElement>(appiumServerUrl, capabilities);
    }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AMING20220827

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值