简体   繁体   English

Java Appium Test无法在AWS Device Farm上运行

[英]Java Appium Test failed to run on AWS Device Farm

I have Appium script in Java language which recoreded by Appium Insecptor. 我有Java语言的Appium脚本,该脚本由Appium Insecptor复核。

My script is going to do only 5 steps: 我的脚本将仅执行5个步骤:

  1. Click username field 点击用户名字段

  2. Input username 输入用户名

  3. Click password field 单击密码字段

  4. Inout password 输入密码

  5. Click login button 点击登录按钮

I would like to run my script on AWS Device Farm. 我想在AWS Device Farm上运行脚本。

I did follow the document of AWS Device Farm to modify my pom.xml file, packaged it by using Maven package mvn clean package -Dskiptests=true and finally uploaded the zip-with-dependencies.zip to AWS Device Farm. 我确实按照AWS Device Farm的文档修改了pom.xml文件,使用Maven软件包mvn clean package -Dskiptests=true打包了该文件,最后将zip-with-dependencies.zip上传到了AWS Device Farm。

But my test failed to run. 但是我的测试无法运行。 Here are the screenshots of the result 这是结果的屏幕截图

我的结果1的屏幕截图我的结果2的屏幕截图

I don't know where I did mistake to make AWS failed to run my script. 我不知道我在哪里犯了错误,使AWS无法运行脚本。

Here is what I recorded, 这是我记录的

package com.hostname.myapp;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

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

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;


public class AppiumTest {

    private static AppiumDriver<AndroidElement> wd;

    @BeforeClass
    public static void setUpClass() throws MalformedURLException {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("appium-version", "1.0");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "5.0.2");
        capabilities.setCapability("deviceName", "XXXXXXXXXXXX");
        capabilities.setCapability("app", "/Users/X/X.apk");
        capabilities.setCapability("appPackage", "com.hostname.myapp");
        wd = new AndroidDriver<AndroidElement>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @AfterClass
    public static void tearDownClass() {
        if (wd != null) {
            wd.quit();
        }
    }

    @Test
    public void test() throws IOException {
        wd.findElement(By.xpath("android.widget.EditText[1]")).click();
        wd.findElement(By.xpath("android.widget.EditText[1]")).sendKeys("username");
        wd.findElement(By.xpath("android.widget.EditText[2]")).click();
        wd.findElement(By.name("Android.widget.EditText[2]")).sendKeys("password");
        wd.findElement(By.xpath("android.widget.Button[1]")).click();
        wd.close();
    } 

I work for the AWS Device Farm team. 我为AWS Device Farm团队工作。

Thank you for the detailed information. 感谢您提供详细信息。 This helps. 这会有所帮助。

Solution

  1. Desired Capabilities : Device farm ignores the desired capabilities that you have used. 所需功能 :设备场将忽略您已使用的所需功能。 Since you upload the app separately in device farm and choose the device while scheduling a run the device type, name and other capabilities that you use in your code will not be honored and any code that depends on it most likely will not work. 由于您是在设备场中分别上传应用程序并在安排运行时选择设备的,因此将不支持您在代码中使用的设备类型,名称和其他功能,并且依赖于此代码的任何代码都将不起作用。 Creating an empty desired capability object and passing that to the AndroidDriver constructor would be the ideal way to approach this. 创建一个空的所需功能对象并将其传递给AndroidDriver构造函数将是实现此目标的理想方法。

  2. Android Driver : The code that you used Android驱动程序 :您使用的代码

    wd = new AndroidDriver<AndroidElement>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);

    should be 应该

    wd = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

  3. Video : We have video recording capability for both iOS and Android. 视频 :我们具有iOS和Android的视频录制功能。 When a test fails it helps immensely if there is a video of that run. 如果测试失败,那么如果有运行该视频的视频,它将提供极大帮助。 You can check this under the "Files" tab. 您可以在“文件”标签下进行检查。 It could be the case that a pop appeared on the device or some other unexpected event while running the test. 可能是在运行测试时设备上出现了弹出声或其他意外事件。 The video should give you more insight in this case. 在这种情况下,视频应该可以为您提供更多的见识。

I would suggest trying these 3 changes. 我建议尝试这3种变化。 Let me know if you are still unable to proceed. 让我知道您是否仍然无法继续。

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS设备场:APPIUM_JAVA_JUNIT_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR - AWS Device Farm: APPIUM_JAVA_JUNIT_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR AWS设备场使用TestNG框架,而不管选择Appium Java Junit进行测试 - AWS-Device farm Uses TestNG Framework Regardless of selecting Appium Java Junit for Testing AWS设备场上的Appium / TestNG脚本-找不到元素 - Appium/TestNG script on AWS device farm - could not find element 如何在 AWS Device Farm 中运行 maven 命令 - How to run maven command in AWS Device Farm AWS Device Farm + Espresso:在AWS Device Farm中运行涉及本机JNI方法调用的Espresso Instrumentation测试 - AWS Device Farm + Espresso: Running Espresso Instrumentation Test involving Native JNI method call in AWS Device Farm 如何以编程方式为AWS-Device Farm设置Appium --no-reset标志 - How to set Appium --no-reset flag programmatically for AWS-Device Farm 当我尝试在 Kobiton 设备农场的 Appium 中运行自动测试时,出现异常 - When I try to run automatic tests in Appium on the Kobiton device farm, I get an exception AWS Device Farm:* -tests.jar文件是在测试包中的zip文件之后构建的 - AWS Device Farm: *-tests.jar file is built after the zip file in the test package 使用具有参数化的 jenkins 执行 Aws 设备场 - Aws device farm execution with jenkins having parametarization Appium:如何使用java中的自动化测试用例检查设备名称 - Appium : how to check device name using automation test cases in java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM