Showing posts with label Appium. Show all posts
Showing posts with label Appium. Show all posts

Road to capture screenshot using Appium java

Use below function to capture screen shot of android application using Appium.

// capturing screenshot
    public void captureScreenshot(String fileName) {
        try {       
            FileOutputStream out = new FileOutputStream( fileName + ".jpg");
            out.write(((TakesScreenshot) driver)
                    .getScreenshotAs(OutputType.BYTES));
            out.close();         
        } catch (Exception e) {      }
    }



Road to automate Network feature of device using Appium

Appium provide NetworkConnectionSetting class using this we can disable and enable network setting of mobile.
Below example show you how to enable and disable network of mobile using Appium.


public void testNetwork()

                    NetworkConnectionSetting networkConnection  = (AndroidDriver driver).getNetworkConnection();

                   networkConnection.setWifi(false);

                    networkConnection.setAirplaneMode(false);

                    networkConnection.setData(true);

                  ((AndroidDriver )driver).setNetworkConnection(networkConnection);

                  networkConnection = ((AndroidDriver )driver).getNetworkConnection();

                 System.out.println("Aireplane Mode status "+networkConnection.airplaneModeEnabled());

                   System.out.println("Data Mode status "+networkConnection.dataEnabled());

                   System.out.println("Wifi Mode status "+networkConnection.wifiEnabled());

}
 









Road to setup and create first Appium Webdriver android script in Java

About Appium:
Appium is open source automation tool for iOS and android application supported by Sauce Lab. It is cross platform, supported Native, Hybrid iOS and android application. At backend it uses webdriver JSON wire protocol to communicate with iOS and android applications.
Appium supported many languages like Webdriver. You can write your test scripts any language that has selenium client library.
Appium support UIAutomator framework for ios and android library (For newer Api) and use selendroid for older android platform.

Road to find android application element details using UI Automator Viewer

In this post I will show you how to find element details of android application using Android “UI Automator Viewer”. Following are the steps:
1. Open android application on emulator or real device. Like I have opened below app on emulator.