1

I am new to mobile app automation testing & have requirement like connect a device with server/console & remotely control the connected device from web. How do I achieve this one. Any suggestions? I tried selendroid for native apps but I don't know how to test with web & device simultaneously.

Ex: My app like "Airdroid"

saravana
  • 544
  • 1
  • 7
  • 26

1 Answers1

1

When you start the Appium server, it starts listening on a specific port. In your test code, you can initialize an AndroidDriver object by passing in a URL object that points to the address Appium is running on.

For example, if Appium is running at www.example.com on port 4723, then my test code on the client side should have the following line:

AndroidDriver driver = new AndroidDriver(new URL("http://www.example.com:4723/wd/hub"),
   capabilities);

The capabilities object is a DesiredCapabilities object that lists parameters and flags for the Appium server. After initializing the AndroidDriver object, you can call AndroidDriver's methods on driver to interact with the device running the app that's connected to the remote server.

I also assumed you already downloaded the Appium Java client for the AndroidDriver class, but in case you haven't, you can add the following to your pom.xml for a Maven project:

<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>2.1.0</version>
</dependency>

And here are links to the Java client and Appium documentation for future reference:

http://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html
http://appium.io/slate/en/master/?java#appium-server-capabilities
https://github.com/appium/java-client/blob/master/README.md

Also be sure to forward your ports in any firewalls you have so connection requests can reach Appium.

AleW
  • 185
  • 1
  • 10
  • thanks for your reply. My problem is need to test some scenarios like, Webdriver should start a URL (console/web) page & Now I need to start testing mobile apps from the launched web page (Webdriver launched URL) & vice versa – saravana Apr 15 '15 at 10:25
  • I have used the same way now & got error like "Exception in thread "main" 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.". Here i was starting Appium server using java code on my local system & Appium server launched properly but when try to execute scripts & getting the above error. Could you help if possible – saravana May 18 '15 at 11:05