Jared Jamieson
Jared Jamieson

Reputation: 13

Specifying localhost when connecting to Appium server through TestComplete

I am trying to connect my computer running TestComplete to a different computer running an Appium server. Currently, I am finding the IP address of the Appium computer via Settings -> WiFi -> Details -> IP Address. Then, I throw this address into TestComplete's 'Connect to Device' Server URL. This looks like "http://01.23.456.789:4723/wd/hub". I want to change it to use 'local' host instead of the direct IP Address as mentioned in this question: I have to specify my local Appium server URL. Where/How can I find the URL?.

When I change my Server URL in TestComplete to looks like: "http://localhost:4723/wd/hub" I get the error: "A connection with the server could not be established". When starting Appium, the host looks like: "0.0.0.0". Leaving this as is and changing it to "localhost" both do not fix my issue. What else is needed in addition to the previously mentioned stack overflow question do I need to do to fix my issue?

Upvotes: 1

Views: 912

Answers (2)

Dermot Canniffe
Dermot Canniffe

Reputation: 36

When the machine running TestComplete uses localhost to start a connection, it is sending a request to itself. Since the appium service isn't running on the same machine as TestComplete, that request will fail.

If what you want to avoid is using an IP address, and you'd rather use more friendly machine names, then you have two options;

Domain Name Services

If your network is using an internal name service (DNS) then each machine probably already has a proper name as well as an IP address. You can ask your network admin or use tracert <IP address> (without the angle brackets) to see if a name for that machine is known or available.

Hosts Alias

If no name is set within the network, then you can create a friendly alias for that IP Address within the Hosts file of the machine running TestComplete;

  1. open Notepad as Adminstrator, by right clicking the application and selecting "Open as Administrator"
  2. open C:\Windows\System32\drivers\etc\hosts
  3. Add a line at the end that reads;
<IP Address> friendlyname # This machine hosts appium
  • again, that's the IP address of the appium system without any angle brackets
  1. You should then be able to use http://friendlyname:4723/wd/hub from TestComplete to reference the Appium server

Upvotes: 0

SmartBearSE
SmartBearSE

Reputation: 61

localhost only works for devices connected directly to the TC machine.

Upvotes: 1

Related Questions