Appium – 未安装 AUT。

huangapple go评论89阅读模式
英文:

Appium - AUT is not installed

问题

以下是您提供的内容的翻译:

我正在测试一个iOS应用程序(在真实设备上),并遇到以下错误:

org.openqa.selenium.SessionNotCreatedException: 无法创建新的远程会话。请检查服务器日志以获取更多详细信息。原始错误:未安装AUT(应用安装程序)。 (警告:服务器未提供任何堆栈跟踪信息)。

如果有人能指出Selenium为什么会抛出此错误,将会很有帮助。我能够手动连接到UFT Mobile设备,它可以正常工作。

我的代码是:

import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.IOSMobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;

// 扩展BaseTest_MobileScripts
public class AppTest {

    public static IOSDriver<IOSElement> appDriver;
    public static DesiredCapabilities capabilities;

    @BeforeSuite
    public void setupAppium() throws MalformedURLException {

        capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone X");
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
        capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "13.7");
        capabilities.setCapability("userName", "username");
        capabilities.setCapability("password", "password");
        capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, "abc.def.geh");

        appDriver = new IOSDriver<IOSElement>(new URL("http://127.0.0.1:8443/wd/hub"), capabilities);
        appDriver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
        appDriver.resetApp();
    }

    @AfterTest
    private static void afterTest() {
        appDriver.resetApp(); // 清除所有应用程序数据和权限。
        appDriver.quit();     // 结束Appium会话。
    }

    @Test (enabled=true) public void myFirstTest() throws InterruptedException {
        appDriver.resetApp();
    }
}

部分堆栈跟踪信息在此处附上 https://pastebin.com/npcDyz2a

英文:

I am testing an iOS application (on a real device) and encountering the following error:

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: AUT is not installed. (WARNING: The server did not provide any stacktrace information).

It would be helpful if someone could point out why the Selenium is throwing this error. I am able to manually connect to the UFT Mobile device and it works fine.

My code is:

import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.IOSMobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;

// extends BaseTest_MobileScripts
public class AppTest {

    public static IOSDriver&lt;IOSElement&gt; appDriver;
    public static DesiredCapabilities capabilities;

    @BeforeSuite
    public void setupAppium() throws MalformedURLException {

        capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, &quot;iPhone X&quot;);
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, &quot;iOS&quot;);
        capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, &quot;13.7&quot;);
        capabilities.setCapability(&quot;userName&quot;, &quot;username&quot;);
        capabilities.setCapability(&quot;password&quot;, &quot;password&quot;);
        capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, &quot;abc.def.geh&quot;);

        appDriver = new IOSDriver&lt;IOSElement&gt;(new URL(&quot;http://127.0.0.1:8443/wd/hub&quot;), capabilities);
        appDriver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
        appDriver.resetApp();
    }

    @AfterTest
    private static void afterTest() {
        appDriver.resetApp(); // Clear all the application data and permissions.
        appDriver.quit();     // End Appium session.
    }

    @Test (enabled=true) public void myFirstTest() throws InterruptedException {
        appDriver.resetApp();
    }
}

The partial stacktrace is attached here https://pastebin.com/npcDyz2a.

答案1

得分: 0

经过多次尝试,我终于找到了一个对我有效的解决方案!

当出现权限弹窗(例如访问摄像头或存储权限)时会发生此错误。

如果您不在自动化流程中授予权限,当测试失败并启动下一个测试时,弹窗不会消失,当 Appium 尝试查找您的应用时,它无法找到,因为权限弹窗会覆盖您的应用。

尝试找出哪个测试需要某些权限,并添加一步来授予该权限。

在我的情况下,项目中的某个人删除了为相机授予权限的步骤,因此我的持续集成流程开始崩溃,当我将这个步骤重新添加到代码中时,这个错误就不再发生。

英文:

After so many tries, i finally got a solution that works to me!!

This error happens when a permision Pop-up (Like permission to acess cam or storage) is showed.

If you dont give the permission in with the automation, when a test fails and start the next, the pop-up dont disappear, and when Appium try to find your app, it can't find, because the permission pop-up is overlapping your application.

Try to find which test need some permission and add a step to give this permission.

In my case, someone in project removes this step which gives the permission for camera, and because that, my CI Pipeline start to crash, when I went back this step to the code, this error stop to happen.

huangapple
  • 本文由 发表于 2020年10月21日 15:13:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/64458411.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定