selendroid / selendroid

"Selenium for Android" (Test automate native or hybrid Android apps and the mobile web with Selendroid.) Join us on IRC #selendroid on freenode. Also confirm you have signed the CLA http://goo.gl/pAvxEI when making a Pull Request.
http://selendroid.io
Apache License 2.0
889 stars 435 forks source link

Error - "INFO: Can't connect to Selendroid server, assuming it is not running." #1076

Open getyourbots opened 8 years ago

getyourbots commented 8 years ago

I've been trying to get selendroid working in the past days, and looks like I'm closer and closer each day, to get it working.

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/user/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/user/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/user/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/user/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/user/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/user/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/user/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/user/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:8080/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-dependecies, 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):
        desired_capabilities = {'aut': 'io.selendroid.testapp:0.17.0'}

        self.driver = webdriver.Remote(
            desired_capabilities=desired_capabilities
        )
        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. Android phone version 4.2.2 and phone is Samsung S3 mini.

Starting the selendroid server with the app argument, gets me one step further. Now, I see on the phone, the test app activity (default test app from selendroid.io), with the buttons and textfields.

Selendroid server tries to start the server (or connect to it), for few time on different ports, and stops by throwing the timeout connection.

I'm trying to automate the browser, on the phone, by sending commands through python. Any suggestions on how to solve this, are appreciated !

jankowskirobert commented 8 years ago

maybe something wrong with your port: http://localhost:1235 why you connecting to 1235 to hub if you have hub on 4444 port?

luiscruz commented 7 years ago

I am having the same problem. It keeps saying:

INFO: Can't connect to Selendroid server, assuming it is not running.

Device: Nexus 5X Android 6.0.1