【问题标题】:Unresponsive Appium Server & Device Offline problems无响应的 Appium 服务器和设备离线问题
【发布时间】:2016-02-11 13:32:24
【问题描述】:

以下是使用 Appium 和 Selenium 执行测试时遇到的一些常见问题 - 特别是在运行数小时的测试时。

一些常见问题是:

  1. 有时在测试进行到一半时,appium 无法连接到设备。日志显示设备离线(即使设备在线且应用可手动访问)
  2. 有时在测试进行到一半时,chromedriver 在 webview 的情况下变得无响应。

问题:

  1. 保持设备不变 - 有没有办法重新启动 Appium 服务器并将其连接到现有的 Android 设备实例。这样我就可以在突然停止的地方恢复测试。

  2. 保持 Appium Server 不变 - 有没有办法在 Android 设备上重新启动 APP 并将其连接到 Appium Server Session 的现有实例。

  3. 有没有办法检查 Appium Server 和/或 Android 设备是否离线/无响应?

【问题讨论】:

    标签: android selenium-webdriver appium


    【解决方案1】:

    您可以通过在命令提示符中点击adb devices 来检查设备是否与 appium 脱机。 如果它只显示设备,则它在线到 appium 服务器

    如果服务器无响应,则可能是间歇性过时会话问题。最好通过点击adb kill-server && sudo adb start-server从命令提示符停止和重新启动服务器

    【讨论】:

      【解决方案2】:
      Few things can help you in minimising these issues drastically:
      0. Put no lock and no screen saver on device.
      1. Always start appium server before starting all tests, in case of testNG/junit framework, start in @BeforeClass or @BeforeTest method.
      2. add this capabilities.setCapability("newCommandTimeout", "120") to appium driver, this will stop appium to timeout early thus avoiding nosessionfound exception etc.
      3. assuming you are using appium v16 and latest chromedriver v20: 
      Problem: Chromedriver normally hangs while switching to and from webview but appium waits for chromedriver to respond until defined timeout and if it doesn't respond, appium gets timeout and then you may see hell lot of new issues like device not online, unknown error etc. 
      Solution: You can keep monitoring chromedriver, when it stops responding, you can start it programmatically, this way your test will get going. 
      Readymade solution: Download chromedriverhandler.jar from 
      1. https://github.com/mi2pankaj/chromeDriverHandler, add to your project,
      2. use this in beforeTest/beforeClass or at the start of your test: ChromedriverHandler.chromeDriverHandlerThread().start();
      3. use this in afterTest/afterClass or at the end of your test: ChromedriverHandler.chromeDriverHandlerThread().stop();
      Hope this helps!!
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-15
        • 2020-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多