How to run test with both selenium & selendroid

494 Views Asked by At

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"

1

There are 1 best solutions below

2
On

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.