首页 > 解决方案 > 移动自动化代码未运行并给出与诱惑相关的错误

问题描述

我是第一次使用 Appium 编写移动自动化测试脚本。我正在尝试运行安装在连接到计算机的 android 手机上的应用程序。我在 Eclipse 上用 Java 编写了代码。我的代码没有运行,我在控制台上看到以下消息:

[RemoteTestNG] detected TestNG version 6.9.10
[TestNG] Running:
N:\eclipse-workspace\TestPro\testng.xml

[main] ERROR io.qameta.allure.AllureLifecycle - Could not stop test container: container with uuid 67e81eee-0a3a-489a-9b83-5f5e3305f573 not found
[main] ERROR io.qameta.allure.AllureLifecycle - Could not write test container: container with uuid 67e81eee-0a3a-489a-9b83-5f5e3305f573 not found

===============================================
Suite
Total tests run: 0, Failures: 0, Skips: 0
===============================================

这就是我设置所需功能的方式 -

@BeforeClass
public void setup()
{
    try
    {
        DesiredCapabilities caps = new DesiredCapabilities();
        
        
        caps.setCapability("deviceName", "R8KN800EJ0J");
        caps.setCapability("platformName", "Android");
        caps.setCapability("platformVersion", "10");
        caps.setCapability("appPackage", "com.jayway.contacts");
        caps.setCapability("appActivity", "com.jayway.contacts.MainActivity");
        caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);
        caps.setCapability("fullReset", false);
        caps.setCapability("noReset", true);
        
        URL url = new URL("http://127/0/0/1:4723/wd/hub");
        driver = new AppiumDriver<MobileElement>(url, caps);
    }
    
    catch(Exception exp)
    {
        System.out.println("Cause: " +exp.getCause());
        System.out.println("Message: " +exp.getMessage());
        exp.printStackTrace();
    }
}

我尝试在我的pom.xml文件中添加 allure 依赖项,并在我的类文件中导入 allure 头文件,但我仍然遇到同样的错误。我不知道魅力是什么以及它是如何工作的,我还没有在我的代码中使用它,但仍然收到错误消息。

请帮忙。

标签: javaautomated-testsappiumandroid-uiautomatorallure

解决方案


我找到了错误背后的原因。

  1. 我在 pom.xml 文件中的依赖项列表中使用了 allure 依赖项
  2. 我忘记在 testng.xml 文件中添加我打算运行的类

一旦我解决了上述问题,代码就成功运行了。


推荐阅读