当前位置: 首页 > 知识库问答 >
问题:

无法在真正的Android设备上运行任何Appium测试。错误参数:BadParametersError:参数不正确

祝高超
2023-03-14

我试图在一个真正的android设备上运行一个Appium测试。Java类是使用Appium Inspector生成的:

package some.package;

import io.appium.java_client.android.AndroidDriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class somename{
    public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("appium-version", "1.5.3");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "6.0.1");
        capabilities.setCapability("deviceName", "d61462ac");
        capabilities.setCapability("app", "/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk");
        capabilities.setCapability("appPackage", "com.package");
        capabilities.setCapability("appActivity", "com.myapp.LaunchApp");
        WebDriver wd = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

        wd.findElement(By.xpath("//android.widget.LinearLayout[1]")).click();
        wd.close();
    }
}

Appium日志如下所示(启动Appium并启动测试脚本):

 Launching Appium with command: 
'/Applications/Appium.app/Contents/Resources/node/bin/node' appium/build/lib/main.js --address "127.0.0.1" --pre-launch --debug-log-spacing --automation-name "Appium" --platform-name "Android" --platform-version "6.0.1" --app "/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk" --dont-stop-app-on-reset --device-name "e20123ee"

[Appium] Welcome to Appium v1.5.3

[Appium] Non-default server args:

[Appium]   address: '127.0.0.1'

[Appium]   launch: true
[Appium]   debugLogSpacing: true
[Appium]   platformName: 'Android'
[Appium]   platformVersion: '6.0.1'
[Appium]   automationName: 'Appium'
[Appium]   deviceName: 'd61462ac'
[Appium]   app: '/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk'
[Appium]   dontStopAppOnReset: true
[Appium] Deprecated server args:
[Appium]   --platform-name => --default-capabilities '{"platformName":"Android"}'
[Appium]   --platform-version => --default-capabilities '{"platformVersion":"6.0.1"}'
[Appium]   --automation-name => --default-capabilities '{"automationName":"Appium"}'
[Appium]   --device-name => --default-capabilities '{"deviceName":"d61462ac"}'
[Appium]   --app => --default-capabilities '{"app":"/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk"}'
[Appium]   --dont-stop-app-on-reset => --default-capabilities '{"dontStopAppOnReset":true}'
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium]   platformName: 'Android'
[Appium]   platformVersion: '6.0.1'
[Appium]   automationName: 'Appium'
[Appium]   deviceName: 'd61462ac'
[Appium]   app: '/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk'
[Appium]   dontStopAppOnReset: true

[Appium] Appium REST http interface listener started on 127.0.0.1:4723

[HTTP] --> GET /wd/hub/status {}

[MJSONWP] Calling AppiumDriver.getStatus() with args: []

[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...

[HTTP] <-- GET /wd/hub/status 200 17 ms - 83 

[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk","appPackage":"com.package","appActivity":"com.myapp.LaunchApp","appium-version":"v1.5.3","platformVersion":"6.0.1","platformName":"Android","deviceName":"d61462ac"},"requiredCapabilities":{},"capabilities":{"desiredCapabilities":{"app":"/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk","appPackage":"com.package","appActivity":"com.myapp.LaunchApp","appium-version":"v1.5.3","platformVersion":"6.0.1","platformName":"Android","deviceName":"d61462ac"},"requiredCapabilities":{}},"alwaysMatch":{"app":"/Users/myuser/Documents/projects/testapplication/build/outputs/apk/myapp-debug.apk","appPackage":"com.package","appActivity":"com.myapp.LaunchApp","appium-version":"v1.5.3","platformVersion":"6.0.1","platformName":"Android","deviceName":"d61462ac"},"firs

[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id"]} and you sent ["desiredCapabilities","requiredCapabilities","capabilities","alwaysMatch","firstMatch"]

我在OSX 10.11.6、Appium 1.5.3、java-client-5.0.0-beta5.jar和selenium-server-standalone-3.3.1.jar上使用Eclipse 4.6.3

使用Appium我可以启动应用程序。但我不能在日食里这么做。

有人能帮我理解我错配置了什么吗?

共有2个答案

羊舌航
2023-03-14

尝试使用以下更改的功能...

capabilities.setCapability("app", "myapp-debug.apk");

确保apk安装在您的Android设备中。

吕鸿文
2023-03-14

您应该检查是否安装了所有库。请看一下下面的图片,让我们知道你是否拥有所有的库。在这之后一切都应该会好起来的。

GSON-x.x.x.jar
Java-client-x.x.x-javadoc.jar
Java-client-x.x.x-sources.jar
java-client-x.x.x.jar
selenium-java-x.x.x.zip
selenium-server-standalone-x.x.x.jar
 类似资料:
  • 我是Appium的新手,尝试使用Appium和Selenium(Java)并行运行2台android设备,但只有1台设备在运行我的测试脚本。下面是我的测试脚本(junit),我很难尝试解决这个问题。我没有同时使用任何网格或云网格(SauceLabs/BrowserStack),因为我现在想在本地监视它。 我不是很确定我需要在这里补充什么细节,但我很乐意回答任何问题和建议,将非常感谢。 提前谢谢!!

  • Appium server检测到设备,但无法发送任何命令,因此未执行任何测试。 我想要的能力 Appium服务器日志 检查更新是否可用 更新可用于新版本1.4.16.1 从https://bitbucket.org/appium/appium.app/downloads/AppiumForWindows_1_4_16_1.zip下载文件 使用命令C:\Program Files(x86)\Appi

  • 我只是尝试用IOS提供的示例应用程序用appium设置IOS。 null null null null

  • 我试图在eclipse中执行这个java代码,使用Appium和一个使用USB连接的实际设备。我无法在设备中对安装在设备中的应用程序进行测试。

  • 我正在用真正的ios设备在mac上测试我的应用程序。当我运行脚本时,它会在Eclipse IDE中显示以下错误:, org.openqa.selenium.无法创建新的远程会话。所需的功能=功能[{app=/用户//下载/XXX. ipa, platformVersion=10.2.1, platformName=iOS, deviceName=Mr. x'S iPod Touch, UDID=*

  • 我不能部署我的应用程序在一个真实的设备上它在模拟器上正常工作,我得到部署错误,但没有在错误选项卡。 这是来自生成输出 2>生成成功。 2> ============生成:1成功,0失败,1最新,0跳过===============部署:0成功,1失败,0跳过============= 即使卸载应用程序后,我无法部署我的应用程序在我的实际设备上,其他应用程序安装精细彻底的VS。