1

I'm trying to automate some actions in a browser, using selendroid. I managed to get the server going. If I go to http://localhost:4444/wd/hub/status, here's the response

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

Showing that the device is also recognized. I'm using a real phone, connected through USB. Everything looks good, but when I start the test script, the phone starts the application, but selendroid server it's telling that it cannot connect.

The output of selendroid is shown below. There is more, but here is from where it starts.

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.

If I leave it running, it's just staying in a loop, keeps showing that error, probably trying to reconnect.

I'm using the latest selendroid version, selendroid-standalone-0.17.0-with-depende, got it from their website: http://selendroid.io

The test script I'm running is written in python. Here it is:

#!/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()

My operating system is archbang, Linux archbang 4.6.4-1-ARCH.

Any suggestions are appreciated

EDIT

I managed to get one step further. Looks like starting selendroid with the app argument set, like this:

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

and changing the desired capabilities in my python test script, like this:

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

Got me on step further. I got the aut using the aapt tool, that comes with the android-sdk. Here's the command I've used:

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

Now, my phone the home activity up pops-up, which didn't before. I'm still getting the error in the selendroid server though, same error.

icebox19
  • 493
  • 3
  • 6
  • 15

1 Answers1

0

I managed to get it working by switching to different operating system. I switched to a ubuntu based one, but I guess it doesn't matter.

icebox19
  • 493
  • 3
  • 6
  • 15