Home » appium-tutorial » Mobile WebApplication Automation with Appium

Newly Updated Posts

Mobile WebApplication Automation with Appium

Prevoius Topic, We are going to learn to perform Mobile WebApplication Automation with Appium, in this tutorial, but before we start let understand about WebApplication Automation.

What is WebApplication Automation in Mobile?

Web Application are the browser specific application, which are hosted in web with specific address or domain name. When we open the browser in mobile device and run our automation test, we call it as web application Automation testing in mobile device.

The mobile device has native applications, hybrid application along with have the provision to open the web application through browser. But to automate the web application is a bit different as what we performed earlier for mobile application.

The locator or the objects for mobile apps(native & hybrid) is different then the locators or objects in mobile web application because of different platform.

The locators in Mobile application is inspect in the same way as we did in Selenium, and also to create or execute the automation script for web application in mobile browser, we need to add few more capabilities .

How to perform Mobile WebApplication Automation with Appium?

To perform the Web apps automation, let consider a scenario and after writing the code, we will see, what are the capabilities are been added and setting performed.

Mobile WebApplication Automation with Appium

Scenario:

  • Open the facebook application in Mobile browser.
  • Under “Create an Account “, Enter first name and last name.

Code:

Note: There are few Reference variable that are predefined these are:

public static DesiredCapabilities capabilities=null;
public AndroidDriver adriver=null;
capabilities =new DesiredCapabilities();
capabilities.setCapability("deviceName","Redmi");
//capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
capabilities.setCapability("platformVersion","9 PKQ1.181203.001");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("chromedriverExecutable","C:\Users\XXXXX\Desktop\Eclipse_Installer\GeckoDriver\chromedriver.exe");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability("appium:chromeOptions",ImmutableMap.of("w3c",false));

try {
System.out.println("Opening the browser------------>");
adriver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
Thread.sleep(3000);
adriver.get("https://www.facebook.com/");
adriver.findElement(By.xpath("//input[@name='firstname']")).sendKeys("Code2test.com");
adriver.findElement(By.xpath("//input[@name='lastname']")).sendKeys("WebView Automation");

adriver.quit();
} catch (Exception e) {
e.printStackTrace();
}

Code Description of above code:

Step 1) Add the below capabilities on the Appium Automation script:

//Create the object of Desired Capability
capabilities =new DesiredCapabilities();
//Define the Device name
capabilities.setCapability(“deviceName”,”Redmi”);
//Define the platform version
capabilities.setCapability(“platformVersion”,”9 PKQ1.181203.001″);
//Define Platform name
capabilities.setCapability(“platformName”,”Android”);
//provide the chrome driver exe path saved in local system with same version as the browser version in mobile device
capabilities.setCapability(“chromedriverExecutable”,”C:\Users\Girvar Singh Negi\Desktop\Eclipse_Installer\GeckoDriver\chromedriver.exe”);
//Define Browser name
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “Chrome”);
//Define the string for chrome option
capabilities.setCapability(“appium:chromeOptions”,ImmutableMap.of(“w3c”,false));

Step 2) Create the object the android Driver passing host, port number along with capabilities as a parameter


adriver = new AndroidDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities)

Step 3) Now open the facebook application on mobile browser

adriver.get(“https://www.facebook.com/”);

Step 4) Now inspect the element for first name using xpath and send the string “Code2tes.com” under First name text box

adriver.findElement(By.xpath(“//input[@name=’firstname’]”)).sendKeys(“Code2test.com”);

Step 5) Inspect the element for last name and send the string under last name text box and at the end close the browser.

adriver.findElement(By.xpath(“//input[@name=’lastname’]”)).sendKeys(“WebView Automation”); adriver.quit()

Conclusion:

So with the below tutorial, we have learned how to automated the web browser application using mobile device and inspect and work with the element on mobile web.


Leave a comment

Your email address will not be published. Required fields are marked *