我正在尝试在真正的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那里做到这一点。
有人可以帮我理解我配置错误吗?
答案 0 :(得分:0)
您应该检查是否安装了所有库。请查看下面的图片,如果您有所有图书馆,请告诉我们。一切都应该在此之后发挥作用。
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
答案 1 :(得分:0)
尝试添加selenium独立服务器2.5。在你的项目中不是3.3.1。
java客户端的BETA4仅适用于版本3.2之前的Selenium。
BETA5支持3.2 +