Device Native App Automation using WebDriver and Appium

Setup Android SDK/ADT and create your first app
https://developer.android.com/sdk/index.html?hl=sk
http://developer.android.com/sdk/installing/bundle.html
http://developer.android.com/training/basics/firstapp/creating-project.html#Eclipse
http://developer.android.com/training/basics/firstapp/running-app.html

Install and start Appium Server
http://automatium.blogspot.in/2013/08/appium-android-example-program-for.html

appium1

appium2

Launch your first app on Android Emulator using WebDriver and Appium

  • Launch android emulator through Android Virtual Device Manager in Eclipse toolbar
  • Run the following program as Java Application using Eclipse
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class DeviceAutomation {

       /**
       * @param args
       */
       public static void main(String[] args) {
              // TODO Auto-generated method stub
              try {
                     WebDriver driver = null;
                     File appDir = new File("C://Users//saikatd//workspace//MyFirstApp//bin");
                     File app = new File(appDir, "MyFirstApp.apk");
                     DesiredCapabilities capabilities = new DesiredCapabilities();
                     capabilities.setCapability("device","Android");
                     capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
                     capabilities.setCapability(CapabilityType.VERSION, "4.2.2");
                     capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
                     capabilities.setCapability("app-package","com.example.myfirstapp");
                     capabilities.setCapability("app-activity","MainActivity");
                     capabilities.setCapability("app", app.getAbsolutePath());
                     driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
                     driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
                     System.out.println(driver.getPageSource().toString());
                     driver.close();
                     driver.quit();
              } catch (Exception e) {
                     System.out.println(e.toString());
              }
       }
}

http://unmesh.me/2013/02/06/ios-automation-with-appium/
RemoteWebDriver

Issue faced:
Appium Error: checking whether adb is present

Resolution:
Set the path as:
ANDROID_HOME=D:\new-adt\adt-bundle\adt\sdk;
Path=D:\new-adt\adt-bundle\adt\sdk\build-tools\android-4.4;D:\new-adt\adt-bundle\adt\sdk\platform-tools;
*Change the above location as per your directory structure

 Other reference: http://maheshambati.wordpress.com/2013/08/23/native-android-apps-automation-with-webdriver-using-appium/

Advertisements
This entry was posted in Information Technology. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s