gpt4 book ai didi

java - 无法在真实的 Android 设备上运行任何 Appium 测试。参数错误 : BadParametersError: Parameters were incorrect

转载 作者:行者123 更新时间:2023-11-29 02:41:16 25 4
gpt4 key购买 nike

我正在尝试在真实的 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 启动该应用程序。但我不能从 Eclipse 中做到这一点。

有人可以帮助我了解我配置错误的原因吗?

最佳答案

您应该检查是否安装了所有库。请查看下图,如果您拥有所有库,请告诉我们。一切都应该在此之后工作。

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

关于java - 无法在真实的 Android 设备上运行任何 Appium 测试。参数错误 : BadParametersError: Parameters were incorrect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43892305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com