【问题标题】:Selendroid - Can't connect to Selendroid server, assuming it is not runningSelendroid - 无法连接到 Selendroid 服务器,假设它没有运行
【发布时间】:2016-07-25 19:15:01
【问题描述】:

我正在尝试使用 selendroid 在浏览器中自动执行一些操作。我设法让服务器运行起来。如果我去http://localhost:4444/wd/hub/status,这是回复

{"value":{"os":{"name":"Linux","arch":"amd64","version":"4.6.4-1-ARCH"},"build":{"browserName":"selendroid","version":"0.17.0"},"supportedDevices":[{"emulator":false,"screenSize":"(480, 800)","serial":"47900eb4d5dc9100","platformVersion":"17","model":"GT-I8200","apiTargetType":"google"}],"supportedApps":[{"mainActivity":"io.selendroid.androiddriver.WebViewActivity","appId":"io.selendroid.androiddriver:0.17.0","basePackage":"io.selendroid.androiddriver"}]},"status":0}

显示设备也被识别。我正在使用通过 USB 连接的真实手机。 一切看起来都不错,但是当我启动测试脚本时,手机启动了应用程序,但 selendroid 服务器却告诉它无法连接。

selendroid 的输出如下图所示。还有更多,但从这里开始。

Jul 25, 2016 10:11:41 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell am instrument -e main_activity io.selendroid.androiddriver.WebViewActivity -e server_port 1235 io.selendroid.io.selendroid.androiddriver/io.selendroid.server.ServerInstrumentation
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->

<--
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 forward tcp:1235 tcp:1235
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->

<--
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.android.impl.AbstractDevice startLogging
INFO: starting logcat:
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.server.model.SelendroidStandaloneDriver waitForServerStart
INFO: Waiting for the Selendroid server to start.
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Checking if the Selendroid server is running: http://localhost:1235/wd/hub/status
Jul 25, 2016 10:11:41 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Can't connect to Selendroid server, assuming it is not running.
Jul 25, 2016 10:11:43 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell echo $EXTERNAL_STORAGE
Jul 25, 2016 10:11:43 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
/storage/emulated/legacy
<--
Jul 25, 2016 10:11:43 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell ls /storage/emulated/legacy/
Jul 25, 2016 10:11:43 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
Alarms
Android
Bluetooth
DCIM
Documents
Download
Movies
Music
Nearby
Notifications
Pictures
Playlists
Podcasts
Ringtones
Sounds
TMemo
<--
Jul 25, 2016 10:11:43 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Checking if the Selendroid server is running: http://localhost:1235/wd/hub/status
Jul 25, 2016 10:11:43 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Can't connect to Selendroid server, assuming it is not running.
Jul 25, 2016 10:11:45 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell echo $EXTERNAL_STORAGE
Jul 25, 2016 10:11:45 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
/storage/emulated/legacy
<--
Jul 25, 2016 10:11:45 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell ls /storage/emulated/legacy/
Jul 25, 2016 10:11:46 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
Alarms
Android
Bluetooth
DCIM
Documents
Download
Movies
Music
Nearby
Notifications
Pictures
Playlists
Podcasts
Ringtones
Sounds
TMemo
<--
Jul 25, 2016 10:11:46 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Checking if the Selendroid server is running: http://localhost:1235/wd/hub/status
Jul 25, 2016 10:11:46 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Can't connect to Selendroid server, assuming it is not running.
Jul 25, 2016 10:11:48 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell echo $EXTERNAL_STORAGE
Jul 25, 2016 10:11:48 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
/storage/emulated/legacy
<--
Jul 25, 2016 10:11:48 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Executing shell command: /home/icebox/Android/Sdk/platform-tools/adb -s 47900eb4d5dc9100 shell ls /storage/emulated/legacy/
Jul 25, 2016 10:11:48 PM io.selendroid.standalone.io.ShellCommand exec
INFO: Shell command output
-->
Alarms
Android
Bluetooth
DCIM
Documents
Download
Movies
Music
Nearby
Notifications
Pictures
Playlists
Podcasts
Ringtones
Sounds
TMemo
<--
Jul 25, 2016 10:11:48 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Checking if the Selendroid server is running: http://localhost:1235/wd/hub/status
Jul 25, 2016 10:11:48 PM io.selendroid.standalone.android.impl.AbstractDevice isSelendroidRunning
INFO: Can't connect to Selendroid server, assuming it is not running.

如果我让它继续运行,它只是停留在一个循环中,不断显示该错误,可能正在尝试重新连接。

我正在使用最新的 selendroid 版本,selendroid-standalone-0.17.0-with-depende,从他们的网站获得:http://selendroid.io

我正在运行的测试脚本是用 python 编写的。这里是:

#!/bin/python2.7

import unittest
from selenium import webdriver

class FindElementTest(unittest.TestCase):

    def setUp(self):
        d = webdriver.DesiredCapabilities.ANDROID
        print d
        self.driver = webdriver.Remote(
            desired_capabilities=d
        )
        self.driver.implicitly_wait(30)

    def test_find_element_by_id(self):
        self.driver.get('and-activity://io.selendroid.testapp.HomeScreenActivity')
        self.assertTrue("and-activity://HomeScreenActivity" in self.driver.current_url)
        my_text_field = self.driver.find_element_by_id('my_text_field')
        my_text_field.send_keys('Hello Selendroid')

        self.assertTrue('Hello Selendroid' in my_text_field.text)

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()

我的操作系统是archbang,Linux archbang 4.6.4-1-ARCH。

欢迎提出任何建议

编辑

我设法更进一步。看起来像用 app 参数集启动 selendroid,像这样:

java -jar selendroid-standalone-0.17.0-with-dependencies.jar -app selendroid-test-app-0.17.0.apk

并在我的 python 测试脚本中更改所需的功能,如下所示:

desired_capabilities = {'aut': 'io.selendroid.testapp'}

让我更进一步。 我使用 android-sdk 附带的aapt 工具获得了 aut。这是我使用的命令:

./aapt dump badging ~/Desktop/selendroid/selendroid-test-app-0.17.0.apk

现在,我的手机弹出了家庭活动,这是以前没有的。我仍然在 selendroid 服务器中收到错误,同样的错误。

【问题讨论】:

    标签: python selenium selenium-webdriver selendroid


    【解决方案1】:

    我设法通过切换到不同的操作系统使其正常工作。我切换到基于 ubuntu 的,但我想这没关系。

    【讨论】:

      猜你喜欢
      • 2023-04-06
      • 1970-01-01
      • 2019-05-24
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      相关资源
      最近更新 更多