首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selendroid -无法连接到Selendroid服务器,假设它没有运行

Selendroid -无法连接到Selendroid服务器,假设它没有运行
EN

Stack Overflow用户
提问于 2016-07-25 19:15:01
回答 1查看 593关注 0票数 1

我试图使用selendroid在浏览器中自动执行一些操作。我设法让服务器启动了。如果我去http://localhost:4444/wd/hub/status,下面是回复

代码语言:javascript
复制
{"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的输出如下所示。有更多,但这里是从哪里开始。

代码语言:javascript
复制
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编写的。下面是:

代码语言:javascript
复制
#!/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 4.6.4-1-ARCH.

如有任何建议请见谅。

编辑

我又走了一步。看起来像使用app参数集启动selendroid,如下所示:

代码语言:javascript
复制
java -jar selendroid-standalone-0.17.0-with-dependencies.jar -app selendroid-test-app-0.17.0.apk

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

代码语言:javascript
复制
desired_capabilities = {'aut': 'io.selendroid.testapp'}

让我更进一步。我用的是aapt工具,这是与android配套的。下面是我使用的命令:

代码语言:javascript
复制
./aapt dump badging ~/Desktop/selendroid/selendroid-test-app-0.17.0.apk

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

EN

回答 1

Stack Overflow用户

发布于 2016-07-28 12:05:11

通过切换到不同的操作系统,我设法让它正常工作。我换了一个基于ubuntu的,但我想这并不重要。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38575749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档