In essence, Appium for mobile web testing is pretty simple, you simply use
RemoteWebDriver to connect to the Appium server.
Use the capabilities to set up the remote webdriver.
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "emulator-5554"); capabilities.setCapability("platformName", Platform.ANDROID); // if you are using an up to date version of android to you can use "Chrome" as the app, // otherwise "browser" is the default 'browser' on Android capabilities.setCapability("app", "browser"); String appiumURL = "http://127.0.0.1:4723/wd/hub"; driver = new RemoteWebDriver( new URL(appiumURL), capabilities); // and then use driver as normal
To get started with Appium:
- install the Android SDK
- configure your physical devices to use USB debugging
- Install Appium desktop app
- You can find your
adb devicesfrom the command line.
If you are working with modern physical device connected via USB then you can probably use
"Chrome" as your
"app" and then drive the Mobile Chrome browser (which handles frames better than the default ‘browser’).
If you are working with the Android VM and an AVD then you’ll probably have to use Level 23 of the API, which will come with ‘browser’ rather than ‘chrome’.
Android N (api level 24) comes with Chrome in the AVD but you’ll have to amend Appium slightly to work with it (I chose not to do that and used level 23 with the AVD, and used Chrome on the physical devices).
We cover all of this in more detail on the course, but each of the sites linked to above has install and getting started instructions.
And if you get everything setup, just connect as a RemoteWebDriver as shown in the code snippet above.
You might have to amend the
@Test code a little to introduce different synchronization, but I was surprised at how compatible it was.
Appium has come a long way in a short time, has overcome enormous challenges and deserves to be the default mobile bridge for Selenium WebDriver.