Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.1k views
by
edited by
Unable to initialise android driver using wifi connection. Always got org.openqa.selenium.remote.UnreachableBrowserException on connecting android mobile using adb tcpip port.

Initilaized tcpip port using given below shell comands.

>> adb tcpip 5555

restarting in TCP mode port: 5555

>> adb connect 192.168.0.108:5555

connected to 192.168.0.108:5555

>> adb devices

List of devices attached

192.168.0.108:5555 device

Started appium its listening on port 4723

Now i have tried to initialise android driver but it not working. Please help.

        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("noReset", "true");

        capabilities.setCapability("BROWSER_NAME", "");

        capabilities.setCapability("VERSION", "5.0.2");

        capabilities.setCapability("deviceName", "vivo");

        capabilities.setCapability("platformName", "Android");

        capabilities.setCapability("appPackage", "test.package");

        capabilities.setCapability("appActivity", "test.activity");

        capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 500000);

       

        driver = new AndroidDriver(new URL("http://192.168.0.108:4723/wd/hub"), capabilities);

Output:-

Dec 16, 2016 11:30:13 AM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'

System info: host: 'thangaraj', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-25-generic', java.version: '1.8.0_111'

Driver info: driver.version: AndroidDriver

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)

at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)

at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)

at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)

at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:36)

at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:114)

at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:132)

at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:92)

at initialize.Setup.initialize(Setup.java:238)

at script.ScriptRunner.setup(ScriptRunner.java:67)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)

at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)

at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)

Thanks in Advance.

1 Answer

0 like 0 dislike
by
selected by
 
Best answer

You have mentioned wrong IP with the command,

>> adb connect 

you should use your device IP here, adb connect <device_IP>. You have used your machine IP.

Commands

$ adb tcpip 5555 –>This will restart adb and make it work over tcpip.
 
Disconnect your device now 
Ensure that your phone is connected to the same wifi network as your PC. 
Get the IP address of your phone (“Settings" -> Wifi -> “Your connected network” -> Your IP address will be shown here) 
Run the ‘adb connect’ command 
 
$ adb connect <your phones ip address>
 
You are now connected. 
To verify that adb has indeed connected successfully, run - 
 
$ adb devices
 
If it shows your device, then you are good to go with either appium or calabash
solution here
by
Mobile IP address is correct as i mentioned. The issue is because of invalid driver URL.

I have done the following changes and works fine.

driver = new AndroidDriver(new URL("http://192.168.0.108:4723/wd/hub"), capabilities);

instead

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

Thanks for the quick reply.
by The go-to Tester (181 points)
Great! Thank you for posting the solution.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...