14

The application I am testing is a web based app. Is it possible to use Appium to test this? On their website it states "Appium is an open source test automation framework for use with native and hybrid mobile apps."

So I am unsure if this will work for my web app as it is not a native app or hybrid app.

Can someone enlighten me?

Thanks!

6 Answers 6

8

First of all, you need to know what kind of web application you want to test. According to information from Saucelabs

there are three types of web application:

  1. Native application
    Yes, you can test it using Appium which is a popular tool for mobile testing.
  2. Hybrid application (Native + webview)
    Yes, you can test it with Appium but with a little trick that you may need to change the context to switch to webview mode. appium.io
  3. Web app (app that is accessible from browser installed on your mobile device, not the one you can download and install)
    Yes, and the details are at appium.io too.

Besides, there is actually another type of app: hybrid app, but with customized webview.
I've been struggling with it recently because I have trouble to find and switch to the webview mode.

6

I have found Appium to be very cumbersome in testing mobile web applications due to the fact that touch actions are not well supported. From a Java standpoint, I have found there to be two main options for talking to Appium: the Selenium RemoteWebDriver and the AppiumDriver from the Appium Java client.

Selenium RemoteWebDriver

Until now I have been able to test our web app on an Android device using the selenium RemoteWebDriver and RemoteTouchScreen. Using Selenium 3.6.0 and Appium 1.6.5, I have tested 4 different methods to click an element:

webDriver.findElement(locator).click();
new Actions(webDriver).moveToElement(findElement(locator)).click().perform();
new RemoteTouchScreen(new RemoteExecuteMethod(webDriver)).singleTap(((Locatable)webDriver.findElement(locator)).getCoordinates());
new TouchActions(webDriver).singleTap(locator);

On Android, the first 3 methods work, but 4 throws a 'not supported' exception. I have opted to use method 1 for clicks/taps and 3 for gestures.

On iOS, methods 1, 2 and 4 throw a 'not yet supported' exception and method 3 does nothing. Since I was not prepared to invest the time to troubleshoot that, we are only testing on Android for now in the hopes that Appium will be improved and iOS will be better supported.

Appium Java client

My experience with the Appium java client (version 5.0.4) was worse still. There doesn't seem to be a comprehensive tutorial on how to do touch actions, only a few code snippets flying around on the interwebs. So my answer to this question is an attempt at creating one.

First instantiate the driver and navigate to a page:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Samsung Android S8");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("platformName", "Android");
MobileDriver appiumDriver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

appiumDriver.navigate().to("https://duckduckgo.com");

Then perform a touch action:

new TouchAction(appiumDriver).tap(appiumDriver.findElement(By.id("search_form_input_homepage"))).perform();

This results in: org.openqa.selenium.WebDriverException: Method has not yet been implemented

From this forum post I deduced that I have to switch context to be able to do touch actions. Attempt two:

appiumDriver.context("NATIVE_APP");
new TouchAction(appiumDriver).tap(appiumDriver.findElement(By.id("search_form_input_homepage"))).perform();

That works. However, only for the By.id selector. I could not find any other selector that works when in the NATIVE_APP context. And since most elements in our web site lack an id, I need an xpath selector. Attempt three:

appiumDriver.context("NATIVE_APP");
new TouchAction(appiumDriver).tap(appiumDriver.findElement(By.xpath("//*[@id=\"search_form_input_homepage\"]"))).perform();

Which resulted in: org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.

Other workarounds that I could think of, such as selecting the WebElement in the CHROMIUM context and then carrying over the location to the NATIVE_APP context is not an option since the coordinate systems differ (browser pixels vs screen pixels).

And don't forget to return to the default CHROMIUM context after each touch action. So the complete code of the only working example becomes:

try {
    appiumDriver.context("NATIVE_APP");
    new TouchAction(appiumDriver).tap(appiumDriver.findElement(By.id("search_form_input_homepage"))).perform();
} finally {
    appiumDriver.context("CHROMIUM");
}

At this point my conclusion is that testing mobile web applications with Appium is not quite there yet.

2

Yes, I'm pretty sure you can, have a look here:

EDIT: outdated link fixed link to appium doc

Also, a related question here

2
1

It is possible, here is example how to create instance for safari in Ruby:

capabilities = {

    :device => 'iPhone Simulator',
    :browserName => 'iOS',
    :version => '7.1',
    :platform => 'Mac',
    :app => 'safari'
  }
  $mobile_browser = Selenium::WebDriver.for(
      :remote,
      :desired_capabilities =>capabilities,
      :url => "your_server/wd/hub")

before download appium and click launch to start appium server.

1
  • This will not work. Browser name must be safari and you must switch to WEBVIEW context to work with web. Sep 6, 2017 at 13:39
0

If you are talking about Mobile web apps, yes you can use Appium for testing them

-1

Yes, it's possible for Appium to test both native and hybrid Apps.

For Windows machine, download: Appium For Windows. For MAC machine, download: Appium dmg file.

Windows need: Just Appium.exe + .apk file(android) + testing device + Android SDK installed.

MAC needs Appium DMG file + .app/.ipa file + testing device + XCODE (provisioning certificate) + ANT + ios-webkit-proxy-debug.

For Web apps, as they are purely browser-based, Appium works well on them also.

Link for reference: https://github.com/appium/appium/blob/master/docs/mobile-web.md

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.