Appium – 未安装 AUT。

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

Appium - AUT is not installed

问题

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

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

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

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

我的代码是:

  1. import io.appium.java_client.ios.IOSDriver;
  2. import io.appium.java_client.ios.IOSElement;
  3. import io.appium.java_client.remote.MobileCapabilityType;
  4. import io.appium.java_client.remote.IOSMobileCapabilityType;
  5. import org.openqa.selenium.remote.DesiredCapabilities;
  6. import org.testng.annotations.AfterTest;
  7. import org.testng.annotations.BeforeSuite;
  8. import org.testng.annotations.Test;
  9. import java.net.URL;
  10. import java.net.MalformedURLException;
  11. import java.util.concurrent.TimeUnit;
  12. // 扩展BaseTest_MobileScripts
  13. public class AppTest {
  14. public static IOSDriver<IOSElement> appDriver;
  15. public static DesiredCapabilities capabilities;
  16. @BeforeSuite
  17. public void setupAppium() throws MalformedURLException {
  18. capabilities = new DesiredCapabilities();
  19. capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone X");
  20. capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
  21. capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "13.7");
  22. capabilities.setCapability("userName", "username");
  23. capabilities.setCapability("password", "password");
  24. capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, "abc.def.geh");
  25. appDriver = new IOSDriver<IOSElement>(new URL("http://127.0.0.1:8443/wd/hub"), capabilities);
  26. appDriver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
  27. appDriver.resetApp();
  28. }
  29. @AfterTest
  30. private static void afterTest() {
  31. appDriver.resetApp(); // 清除所有应用程序数据和权限。
  32. appDriver.quit(); // 结束Appium会话。
  33. }
  34. @Test (enabled=true) public void myFirstTest() throws InterruptedException {
  35. appDriver.resetApp();
  36. }
  37. }

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

英文:

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

  1. 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:

  1. import io.appium.java_client.ios.IOSDriver;
  2. import io.appium.java_client.ios.IOSElement;
  3. import io.appium.java_client.remote.MobileCapabilityType;
  4. import io.appium.java_client.remote.IOSMobileCapabilityType;
  5. import org.openqa.selenium.remote.DesiredCapabilities;
  6. import org.testng.annotations.AfterTest;
  7. import org.testng.annotations.BeforeSuite;
  8. import org.testng.annotations.Test;
  9. import java.net.URL;
  10. import java.net.MalformedURLException;
  11. import java.util.concurrent.TimeUnit;
  12. // extends BaseTest_MobileScripts
  13. public class AppTest {
  14. public static IOSDriver&lt;IOSElement&gt; appDriver;
  15. public static DesiredCapabilities capabilities;
  16. @BeforeSuite
  17. public void setupAppium() throws MalformedURLException {
  18. capabilities = new DesiredCapabilities();
  19. capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, &quot;iPhone X&quot;);
  20. capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, &quot;iOS&quot;);
  21. capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, &quot;13.7&quot;);
  22. capabilities.setCapability(&quot;userName&quot;, &quot;username&quot;);
  23. capabilities.setCapability(&quot;password&quot;, &quot;password&quot;);
  24. capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, &quot;abc.def.geh&quot;);
  25. appDriver = new IOSDriver&lt;IOSElement&gt;(new URL(&quot;http://127.0.0.1:8443/wd/hub&quot;), capabilities);
  26. appDriver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
  27. appDriver.resetApp();
  28. }
  29. @AfterTest
  30. private static void afterTest() {
  31. appDriver.resetApp(); // Clear all the application data and permissions.
  32. appDriver.quit(); // End Appium session.
  33. }
  34. @Test (enabled=true) public void myFirstTest() throws InterruptedException {
  35. appDriver.resetApp();
  36. }
  37. }

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:

确定