FANDOM


Basics of Windows (7):

Setup:

1. Make sure you have Android SDK Manager. (Use this to create an AVD. This is the Android Virtual Device or emulator.)

2. Make sure you have an example test and App.

3. Download Appium.exe.


Running:

1. Run Appium.exe and click launch. (No settings need to be changed.)

2. Via Android SDK Manager "start" an AVD. (I havn't gotten anything below API 16 to work. So for now make sure it is an 16+. 18 is great at this time and really fast.)

3. With Appium and the AVD(emulator) running you are ready to try out your test.

- Create a Web Driver.

- Give it capabilities.

 - App, App path, App Package, App Activity, Device, Version, Platform, AppiumServerUrl

- try out some code.

- finish with driver.quit


Important Tid Bits:

1. Speed it up using Intel x86 with Haxm (spelling?).

- This will require you to disable V technology. Enable the other Intel Technologies. (Do this in the BIOS.)



HERE is some example code using Scala and a the Scala Test framework. The Concepts apply in any language though.

  test("Running WebApp With Older SDK and Selendroid") {
    withSelendroid(implicit driver => {

        // YOUR TEST HERE

    },appName, appDir, appPackage, appActivity, device, version, 
      platform, appiumServer)
  }


  /**
   * First Run a Emulator
   * Second Run Appium.exe (Windows/Mac) or Node.js(Linux)
   * Presets to Android 4.3, Windows if no device specified
   * @param testCode put your test code in here
   * @param appPackage package of app - used for android tests
   * @param appName name of app
   * @param appDir  directory of app
   * @param appActivity name of app activity - used for android tests
   * @param device device - used for android tests
   * @param version version
   * @param platform platform - ios or Android
   * @param appiumServer server url - default is http://127.0.0.1:4723/wd/hub
   */

  def withAppium(testCode: RemoteWebDriver => Any, appName: String, 
    appDir: String, appPackage: String = "", appActivity: String = "",
    device: String = "", version: String = "", platform: String = "", 
    appiumServer: String = "http://127.0.0.1:4723/wd/hub") {

    // SHARED STUFF
    val app = new File(new File(appDir), appName)
    val capabilities = new DesiredCapabilities()
    capabilities.setCapability(CapabilityType.VERSION, version)
    capabilities.setCapability(CapabilityType.PLATFORM, platform)
    capabilities.setCapability("app", app.getAbsolutePath)

    // NOT SHARED STUFF
    val driver: RemoteWebDriver = {
      device.toLowerCase match {
        case "ios" => {
          println("IOS device......")
          capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS")
          new RemoteWebDriver(new URL(appiumServer), capabilities)
        }
        case _ => {
          println("Android device......")
          capabilities.setCapability("device", device)
          capabilities.setCapability(CapabilityType.BROWSER_NAME, "")
          capabilities.setCapability("app-package", appPackage)
          capabilities.setCapability("app-wait-activity", appActivity)
          capabilities.setCapability("app-activity", appActivity)
          new RemoteWebDriver(new URL(appiumServer), capabilities)
        }
      }
    }
    try {
      testCode(driver)
    } catch {
      case e: MalformedURLException => println("If running an Android app, it"+
        " might have an incorrect Activity Selected."); throw e
    } finally {
      driver.quit()
    }

  }