2016-07-25 77 views
1

我试图使用selendroid在浏览器中自动执行一些操作。我设法让服务器去。如果我去http://localhost:4444/wd/hub/status,这里是回应Selendroid - 无法连接到Selendroid服务器,假设它没有运行

{"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. 

如果我离开它运行,它只是停留在一个循环,不断显示该错误,可能试图重新连接。 http://selendroid.io

测试脚本我正在用Python编写:

我使用的是最新版本的selendroid,selendroid-独立-0.17.0或更新与 - depende,从他们的网站得到它。这里是:

#!/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。

任何建议都赞赏

编辑

我设法进了一步。貌似开始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'} 

再给我一步。 我得到了aut使用了aapt工具,它与android-sdk一起提供。这里是我用过的命令:

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

现在,我的手机家庭活动弹出,这从来没有。尽管如此,我仍然在selendroid服务器中收到错误,但是同样的错误。

回答

0

我设法通过切换到不同的操作系统来工作。我切换到基于Ubuntu的,但我想这没关系。