【问题标题】:Appium test not going any further after Splash Screen启动画面后 Appium 测试不再进行
【发布时间】:2020-03-07 03:09:13
【问题描述】:

我希望有人可以提供帮助。 我正在测试三个应用程序,其中正确的行为应该是应用程序启动后,启动屏幕显示几秒钟,然后显示登录页面。

我正在尝试使用 appium 自动执行此操作,但是一旦自动测试打开初始屏幕,测试就会结束。 我看到这条错误消息:

NoSuchElementError: An element could not be located on the page using the given search parameters. at AndroidUiautomator2Driver.findElOrEls (C:\Users\zminhas\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)

这是我的 env.rb 代码:

require "appium_lib"
require "pry"


opts = {
         caps: {
           deviceName: :Anyname,
           platformName: :Android,
           app: 'C:\Users\zminhas\Desktop\three_app_automation\features\support\biometrics.apk',
           appPackage: "com.hutchison3g.planet3",
           appActivity: ".SplashScreenActivity",
           noReset: true
         },
         appium_lib: {
           #wait_timeout: 30

         }
       }
Appium::Driver.new(opts, true).start_driver
Appium.promote_appium_methods Object

还有我的 hooks.rb 代码:

Before do
    $driver.start_driver    
end

After do
    $driver.driver_quit
end

这是完整的结果屏幕:

$ cucumber
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
Feature: All external URLs work as expected within the More Tab

2019-11-11 12:08:13 WARN Selenium [DEPRECATION] Selenium::WebDriver::Error::TimeOutError is deprecated. Use Selenium::WebDriver::Error::TimeoutError (ensure the driver supports W3C WebDriver specification) instead.
  Scenario: test                        # features/more_tab.feature:3
    Given I see the enter number screen # features/step_definitions/more_tab_steps.rb:1
      An element could not be located on the page using the given search parameters. (Selenium::WebDriver::Error::NoSuchElementError)
      NoSuchElementError: An element could not be located on the page using the given search parameters.
          at AndroidUiautomator2Driver.findElOrEls (C:\Users\zminhas\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
      ./features/step_definitions/more_tab_steps.rb:2:in `"I see the enter number screen"'
      features/more_tab.feature:4:in `Given I see the enter number screen'

Failing Scenarios:
cucumber features/more_tab.feature:3 # Scenario: test

1 scenario (1 failed)
1 step (1 failed)
0m14.888s

感谢您的宝贵时间

【问题讨论】:

  • 我已经尝试使用“睡眠”功能,但仍然没有乐趣

标签: ruby mobile automation appium


【解决方案1】:

尝试以下功能

           deviceName: :Anyname,
           platformName: :Android,
           automation_name: :uiautomator2,
           app: 'C:\Users\zminhas\Desktop\three_app_automation\features\support\biometrics.apk',
           appPackage: "com.hutchison3g.planet3",
           appActivity: ".SplashScreenActivity",
           noReset: true

【讨论】:

  • 嗨@Mani 谢谢你的建议。不幸的是,我仍然遇到同样的错误。
  • 请发布您的 appium 日志以进一步调试此问题
  • 嗨@Mani 日志太长,无法放入此 cmets 部分,因此请通过此 google drive 链接查看:docs.google.com/document/d/… 谢谢
  • 嗨@Mani 我找到了解决方案。我在 env.rb 中添加了appWaitActivity。这允许加载第二页。感谢您的宝贵时间,祝您一切顺利
【解决方案2】:

在面试中给我一个应用程序时,我遇到了同样的问题。但 2 天后,我能够找到解决与启动画面相关的问题的解决方案,但无法使用脚本/appium 进入第二个屏幕,但手动它工作正常。 问题与意图活动有关 解决方案: 我在 appium 的脚本/功能中添加了一些额外的代码行,它运行良好。 尝试在有启动画面问题的应用程序中使用这些行。

capabilities.setCapability("androidCoverage","com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation");
capabilities.setCapability("androidCoverageEndIntent","com.example.pkg.END_EMMA");
capabilities.setCapability("intentAction","android.intent.action.MAIN");
capabilities.setCapability("intentCategory","android.intent.category.LAUNCHER");
capabilities.setCapability("intentFlags","0x10200000");

请告诉我它是否也对您有用?

【讨论】:

    猜你喜欢
    • 2020-09-17
    • 1970-01-01
    • 2014-03-23
    • 2021-06-27
    • 2020-08-16
    • 2019-07-19
    • 1970-01-01
    • 2013-09-10
    • 2015-01-08
    相关资源
    最近更新 更多