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());

}
 









Java TestNg Selenium Webdriver Training syllabus

Syllabus of Training Session:

TestNG:
1. What is TestNg
2. Installing TestNg in Eclipse
3. TestNg annotations
4. Understanding usage of annotations
5. Running a Test in TestNg
6. Batch Running of tests in TestNg
7. Skipping Tests
8. Parameter zing Tests – DataProvider
9. Assertions/Reporting Errors
10. TestNg Reports
11. Advantages over Junit

Page Object Model for selenium webdriver

Like QTP, TestComplete and few other automation tools selenium webdriver does not provide any centralized repository where we can put object locator of page element. In POM object pattern we can accomplish this type approach.

What is POM:
In automated web testing, a Page Object is a class or object that represents a web page in your application. A Page Object hides the technical details about how you interact with a web page behind a more readable and business-focused facade. Following are the few points in details:
Page Object Model is a design pattern to create Object Repository for web UI elements. Like it provide you to option to put all locators in corresponding page (java file ) like for home page you  create a homepage java file and put all element locators of home page in same class.
Under this model, you should create java file like above ( homePage.java ) home page and create functions related to this page  like clickHomeMenu, clickProduct() verfiyHomePage() etc.
So your page object class contains elements locator and corresponding function what you need to perform on that particular page.
Name of these function and object locator must be logically defined like elements name username , password, loginButoon and corresponding function should be like enterUserName(), enterPassword(), clickLoginButton()

Road to capture android log using java code

In this post I will show you how to capture android log using java code.
public static void captureAndroidDevicesLog() {
  try {
   Process process = Runtime.getRuntime().exec("adb logcat");

   BufferedReader reader = new BufferedReader(new InputStreamReader(
         process.getInputStream()));
   String s;
   System.out.println("*********************************************");
   System.out.println("Printing android logs");
   System.out.println("*********************************************");
   while ((s = reader.readLine()) != null) {
    System.out.println(s);
   }
   System.out.println("*********************************************");
   System.out.println("End printing android logs");
   System.out.println("*********************************************");
  } catch (IOException e) {
   e.printStackTrace();
  } 
}

Above code capture all log of android device and print in console. Yo can manupulate as per you need.