Sunday, February 25, 2018

Automate It! v.1.3 released

Automate It! Web/Mobile Test Automation Framework v1.3 - 21 February 2018

Download the framework here: https://github.com/SWAutoTester/automateit

Thank you for downloading and using most flexible and powerful Java-based test automation framework using Selenium/Appium for web/mobile application testing.

Comments for improvement are very welcome.

Features:

1) Drive automated tasks using latest and greatest Selenium WebDriver and Appium Mobile Drivers using a configuration file
2) Obfuscation of selenium API / no test code changes for testing web and mobile applications
3) Ability to configure mandatory waits in test execution
4) Handles jquery/prototype page load waiting
5) Handles complexity of waiting for all ajax call completion
6) Data Input and Output for easy data driven input file reading (Excel; xlsx, xls - pipe-delimited; "|", and comma separated values (CSV))
7) Special IE handling of user-prompt authentications
8) Page loading performance statistics for each page created during the test, and a summary analysis of all page loading during the executions of all test cases.
9) Debugging help in reports:
   a) selenium/webdriver command list
   b) Screenshots for mobile screen, web browser, and desktop
   c) video recording of test case execution in .mov or .mp4 format (QuickTime and MPEG-4)
10) Easy text-based page content validation
11) Text-To-Speech conversion and player to send audio commands to Siri, Alexa, etc.
12) Speech-To-Text to listen to response from app and translate to text for response validation.
13) OCR (Optical Character Recognition)
14) Scrolling web pages up/down from Safari, Chrome, Firefox web browsers

This framework allows anyone with basic Java programming skills to write automated tests without needing any knowledge of Selenium or Appium WebDrivers.

a) Avoid re-writing of test code by using a single configuration file to drive tests across all browsers and mobile devices.
b) Have a better understanding of application user experience with individual page loading statistics for each page during test case execution.
c) Quick diagnosis of test failures.

Required Software Installation:

1) Java Development Kit - http://www.oracle.com/technetwork/java/javase/downloads/index.html
2) Ant - http://ant.apache.org

Instructions to build the framework:

It's very simple to build and use. After downloading the code, type "ant" and the code will compile and create a jar file with the classes in the "dist" directory.

Copy the jar files from "lib" and "dist" and also copy the configuration files "conf" directory to your test project and modify them for your test settings.

Third Party API Dependency Versions:

FirefoxDriver
-------------
v0.19.1
https://github.com/mozilla/geckodriver/releases
https://github.com/mozilla/geckodriver/releases/tag/v0.19.1

ChromeDriver
-------------
v2.35
https://sites.google.com/a/chromium.org/chromedriver/downloads
https://chromedriver.storage.googleapis.com/index.html?path=2.35/

SafariDriver
------------
Latest version of SafariDriver comes embedded in latest Safari browser

Selenium Server
---------------
v3.8.1
https://goo.gl/hvDPsK
http://www.seleniumhq.org/download/

Appium Drivers
--------------
v6.0.0-BETA2
http://appium.io/downloads.html
https://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.appium%20a%3Ajava-client

Log4J
------
Apache Log4j API 2.10.0 API
https://logging.apache.org/log4j/2.x/download.html

Wednesday, October 18, 2017

Add text-to-speech audio in your tests to control voice-activated features

With so many apps now being directed by voice commands (Siri, Alexa), it's important to have this capability in your automated tests.

But it also needs to be able to direct an application using many languages: English, Spanish, Mandarin, etc.

The Automate It! Test Automation Framework gives you the ability to do that and more:

  • Text to speech conversion
  • Playback in the audio of your computer or testing device
  • Handle different accents and dialects
  • Supports translation and speech to most other languages
It is incredibly simple to do, and there is an example in the framework. 

Here are the steps:
  1. Download the code here: https://github.com/SWAutoTester/automateit
  2. Open a command-prompt terminal window, change directory to the root directory where you downloaded the framework
  3. type "ant example_texttospeech"
You will hear the following audio played on your computer: "Hello and Welcome to the Automate It Test Automation Framework" in both native english (no accent) and english-MX (english spoken with mexican/spanish accent), and native spanish (mexican accent).

It's really easy. Let's take a look at some code.


package org.automateit.example.test;

import org.testng.annotations.Test;

import org.automateit.test.TestBase;

import org.automateit.media.JarvisTextToSpeechConverter;
import org.automateit.media.TextToSpeechConverter;
import org.automateit.media.JLayerAudioPlayer;
import org.automateit.media.AudioPlayer;

/**
 * This class shows an example of how to use the AutomateIt! framework
 * for testing a text-to-speech application.
 * 
 * @author mburnside
 */
public class TextToSpeechTests extends TestBase {
    
    /**
     * The text to speech converter used in this test
     */
    protected TextToSpeechConverter textToSpeechConverter = new JarvisTextToSpeechConverter();
    
    /**
     * The audio player used in this test
     */
    protected AudioPlayer audioPlayer = new JLayerAudioPlayer();
   
    /**
     * Read in a text that has a Welcome message and play the audio on the computer
     *
     * @throws Exception 
     */
    @Test(description = "Read in a text Hello There and play the audio on the computer", groups = { "example_texttospeech" })
    public void test_A_Convert_Text_To_Speech_Welcome_Message_English() throws Exception {
      
        try { audioPlayer.play(textToSpeechConverter.execute("Hello and welcome to the Automate It Test Automation Framework")); }
        catch(Exception e) { throw e; }
    
    }
    
    /**
     * Read in a text that has a Welcome message and play the audio on the computer
     *
     * @throws Exception 
     */
    @Test(description = "Read in a text Hello There and play the audio on the computer - Spanish accent", groups = { "example_texttospeech" })
    public void test_B_Convert_Text_To_Speech_Welcome_Message_Spanish_Accent() throws Exception {
      
        try { audioPlayer.play(textToSpeechConverter.execute("Hello and welcome to the Automate It Test Automation Framework", "es-MX")); }
        catch(Exception e) { throw e; }
    
    }
    
    /**
     * Read in a text that has a Welcome message and play the audio on the computer
     *
     * @throws Exception 
     */
    @Test(description = "Read in a text Hello There and play the audio on the computer - native spanish language", groups = { "example_texttospeech" })
    public void test_C_Convert_Text_To_Speech_Welcome_Message_Spanish() throws Exception {
      
        try { audioPlayer.play(textToSpeechConverter.execute("Hola, tu estas bueno tambien?", "es-MX")); }
        catch(Exception e) { throw e; }
    
    }
    
}

And that's it! Very simple, easy and fast.

In this example, it shows a demonstration of how easy text-to-speech conversion is using the framework and also the added flexibility of supporting:
  1. Many langauges
  2. Many languages with regional accents
Try it out and have fun adding it to your automated tests.



Friday, October 13, 2017

Want Video of your automated tests? Use AutomateIt! Test Automation Framework

Video capture of automated tests in the test result report is an important part of the information needed when your automated tests fail.

If you are using the AutomateIt! Test Automation Framework to run your tests, then all you will need to do is add a few Listeners to the TestNG task listeners attribute, and the framework will take care of everything without you needing to write a single line of code.

Here is what you need to do:

In the example "build.xml" file provided in the download example, look at this line:

<testng outputdir="results/" groups="ios" useDefaultListeners="false" listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter,org.automateit.testng.SeleniumCommandCaptureListener,org.automateit.testng.GenericScreenCaptureListener,org.automateit.testng.MobileScreenCaptureListener,org.automateit.testng.MOVVideoCaptureListener,org.automateit.testng.AVIVideoCaptureListener">

So you just need to add use these two listeners to your existing "listeners" attribute values:


  1. org.automateit.testng.MOVVideoCaptureListener
  2. org.automateit.testng.AVIVideoCaptureListener

That's it! :)

You dont need to write any code. The framework will record the example and provide the recordings in the test result report.

See these screenshots - they will show you where they will appear in the report:



The all you need to do is click on the link to view.

Here are some of the real examples after running the tests:




Thursday, October 12, 2017

Automate your iOS mobile application tests in 10 minutes

The Automate It! Test Automation Framework open source project literally enables your test developers to automate your entire application or parts of your application screen in merely 10 minutes.

As a demonstration, I have put together a simple Login Screen login on a demo iOS mobile application, similar to what most applications present to a user upon entering their product or service.



This app is simple: The user enters a username and password and then clicks on the Login button to login.

There are several use cases we can drive using data to completely test this authentication feature within 10 minutes - development and test time COMBINED!

So here are some of the test obvious test cases:


  • User logs in successfully with a valid username and password.
  • The user tries different combinations of incorrect username and password - perhaps forgetting either the username or password for their account.
  • The user tries backdoor hacking with blank username and password combinations hoping to find a flaw in the system.


AutomateIt! Test Automation has you covered.

All you need to do is map the application using Appium Desktop application for v1.7.1 server and embed them in a simple java class indicating the resource id's (or perhaps obtain an Xpath element locator via Appium Desktop) and away you will go.

Here is a screenshot of rendering the App in Appium Desktop and letting it tell you what the element locators are:



So now we embed them in a very elegant class structure: a base class and an iOS-specific class. Why not just one single class? Because then we can map our iOS app and use the existing base classes to drive those tests also with 10% of the effort to create the framework and iOS-specific screen classes (which only took us 10 minutes anyways!).

The test classes use the screen interactivity capability of these Login screen classes to drive tests using a data file - no hard coding!

Ok, here are the steps to run these tests on your system;
  1.  Download (free and open-source) AutomateIt! Test Automation Framework here (this example is included): https://github.com/SWAutoTester/automateit
  2. Make sure that the latest Java and Ant is installed on your system
  3. Install Xcode 9 (no actual device required!)
  4. Install appium as a service and start it: http:// appium.io
  5. Open the file for edit: /conf/configuration.properties.ios.properties and change the "app_location" property to the directory where you downloaded the AutomateItIOSDempApp.ipa file (included in the download as a demo application) in "resources/ios/" directory.
  6. Navigate to the directory that you downloaded the framework, and open up a terminal window command prompt.
  7. Change directory to <download_directory>. Then type "ant ios".
  8. The test will run and finish in 5 minutes.
  9. Navigate to "results/html/index.html" to see the results and additional information included in the report: framework/webdriver commands list, screenshots, video's in AVI and MOV format that recorded the tests for you.


Give it a try, and contact me if you any problems.

The code resides here:

/automateit/src/org/automateit/example/screen
/automateit/src/org/automateit/example/test
/automateit/conf/configuration.properties.ios.properties
/automateit/data/login.csv

Here is some code to show you how easy it is using a data-driven input file:

    /**
     * Try to login
     * 
     * @param usernameDataSetId
     * @param passwordDataSetId
     * 
     * @throws Exception 
     */
    public void executeLoginAttempt(String usernameDataSetId, String passwordDataSetId) throws Exception {
      
        try { 
            
            if(usernameDataSetId != null) loginScreen.enterUsername(testData.returnInputDataForDataIdAndColumnNumber(usernameDataSetId, 1));
            else loginScreen.enterUsername("");
            
            if(passwordDataSetId != null) loginScreen.enterPassword(testData.returnInputDataForDataIdAndColumnNumber(passwordDataSetId, 1));
            else loginScreen.enterPassword("");
            
            loginScreen.clickLoginButton();
            
        }
        catch(Exception e) { throw e; }
    
    }

This does the actual interaction with the login screen:

    /**
     * Enter text into the Username text field.
     * 
     * @param username The username
     * 
     * @throws Exception 
     */
    public void enterUsername(String username) throws Exception {
        
        try {
            
            clearWebElementByResourceId(resourceId_textfield_username);
            
            enterDataIntoWebElementByResourceId(resourceId_textfield_username, username);
           
        }
        catch(Exception e) { throw e; }
        
    }
    
    /**
     * Enter text into the Password text field.
     * 
     * @param password The password
     * 
     * @throws Exception 
     */
    public void enterPassword(String password) throws Exception {
        
        try {
            
            clearWebElementByResourceId(resourceId_textfield_password);
            
            enterDataIntoWebElementByResourceId(resourceId_textfield_password, password);
            
        }
        catch(Exception e) { throw e; }
    }
    
    /**
     * Click/Tap on the "Sign In" button.
     * 
     * @throws Exception 
     */
    public void clickLoginButton() throws Exception {
        
        try { clickUsingResourceId(resourceId_button_login); }
        catch(Exception e) { throw e; }
        
    }



Notice in this code snippet that you dont have to have any knowledge of WebDriver because the framework handles all of that for you so you can focus only our your application.

Wednesday, October 11, 2017

Automate your Android mobile application tests in 10 minutes

The Automate It! Test Automation Framework open source project literally enables your test developers to automate your entire application or parts of your application screen in merely 10 minutes.

As a demonstration, I have put together a simple Login Screen login on a demo Android mobile application, similar to what most applications present to a user upon entering their product or service.



This app is simple: The user enters a username and password and then clicks on the Login button to login.

There are several use cases we can drive using data to completely test this authentication feature within 10 minutes - development and test time COMBINED!

So here are some of the test obvious test cases:


  • User logs in successfully with a valid username and password.
  • The user tries different combinations of incorrect username and password - perhaps forgetting either the username or password for their account.
  • The user tries backdoor hacking with blank username and password combinations hoping to find a flaw in the system.


AutomateIt! Test Automation has you covered.

All you need to do is map the application using Appium Desktop application for v1.7.1 server and embed them in a simple java class indicating the resource id's (or perhaps obtain an Xpath element locator via Appium Desktop) and away you will go.

Here is a screenshot of rendering the App in Appium Desktop and letting it tell you what the element locators are:



So now we embed them in a very elegant class structure: a base class and an Android-specific class. Why not just one single class? Because then we can map our iOS app and use the existing base classes to drive those tests also with 10% of the effort to create the framework and android-specific screen classes (which only took us 10 minutes anyways!).

The test classes use the screen interactivity capability of these Login screen classes to drive tests using a data file - no hard coding!

Ok, here are the steps to run these tests on your system;


  1.  Download (free and open-source) AutomateIt! Test Automation Framework here (this example is included): https://github.com/SWAutoTester/automateit
  2. Make sure that the latest Java and Ant is installed on your system
  3. Install Android Studio and create a Emulator/Simulator that can run on your desktop (no actual device required!), configured for using version 6.X.
  4. Start you simulator and let it boot up completely.
  5. Install appium as a service and start it: http:// appium.io
  6. Open the file for edit: /conf/configuration.properties.android.properties and change the "app_location" property to the directory where you downloaded the app-debug.apk file (included in the download as a demo application) in "resources/android/" directory.
  7. Navigate to the directory that you downloaded the framework, and open up a terminal window command prompt.
  8. Change directory to <download_directory>. Then type "ant android".
  9. The test will run and finish in 5 minutes.
  10. Navigate to "results/html/index.html" to see the results and additional information included in the report: framework/webdriver commands list, screenshots, video's in AVI and MOV format that recorded the tests for you.




Give it a try, and contact me if you any problems.

The code resides here:

/automateit/src/org/automateit/example/screen
/automateit/src/org/automateit/example/test
/automateit/conf/configuration.properties.android.properties
/automateit/data/login.csv

Here is some code to show you how easy it is using a data-driven input file:

    /**
     * Try to login
     * 
     * @param usernameDataSetId
     * @param passwordDataSetId
     * 
     * @throws Exception 
     */
    public void executeLoginAttempt(String usernameDataSetId, String passwordDataSetId) throws Exception {
      
        try { 
            
            if(usernameDataSetId != null) loginScreen.enterUsername(testData.returnInputDataForDataIdAndColumnNumber(usernameDataSetId, 1));
            else loginScreen.enterUsername("");
            
            if(passwordDataSetId != null) loginScreen.enterPassword(testData.returnInputDataForDataIdAndColumnNumber(passwordDataSetId, 1));
            else loginScreen.enterPassword("");
            
            loginScreen.clickLoginButton();
            
        }
        catch(Exception e) { throw e; }
    
    }

This does the actual interaction with the login screen:

    /**
     * Enter text into the Username text field.
     * 
     * @param username The username
     * 
     * @throws Exception 
     */
    public void enterUsername(String username) throws Exception {
        
        try {
            
            clearWebElementByResourceId(resourceId_textfield_username);
            
            enterDataIntoWebElementByResourceId(resourceId_textfield_username, username);
           
        }
        catch(Exception e) { throw e; }
        
    }
    
    /**
     * Enter text into the Password text field.
     * 
     * @param password The password
     * 
     * @throws Exception 
     */
    public void enterPassword(String password) throws Exception {
        
        try {
            
            clearWebElementByResourceId(resourceId_textfield_password);
            
            enterDataIntoWebElementByResourceId(resourceId_textfield_password, password);
            
        }
        catch(Exception e) { throw e; }
    }
    
    /**
     * Click/Tap on the "Sign In" button.
     * 
     * @throws Exception 
     */
    public void clickLoginButton() throws Exception {
        
        try { clickUsingResourceId(resourceId_button_login); }
        catch(Exception e) { throw e; }
        
    }



Notice in this code snippet that you dont have to have any knowledge of WebDriver because the framework handles all of that for you so you can focus only our your application.











Sunday, October 8, 2017

Easily drive your tests using Excel, Comma-Separated, or Pipe-Delimited files

The AutomateIt! Test Automation open source project framework allows you to easily read and write data from several popular and cross-platform formats:

  • Excel (.xls, .xlsx)
  • CSV - Comma-Separated Values (.csv)
  • Pipe-Delimited Format ("|")

Here is an example of how easy it is to do for your tests.

Steps:

1) Download the AutomateIt! Test Automation framework from the open source directory at GIT: https://github.com/SWAutoTester/automateit

2) Open a command-line terminal prompt and go to the directory where you downloaded the code in Step 1.

3) type "ant example_read_input_data"

The tests will run and you should see this output on your screen:


example_read_input_data:
   [testng] [TestNG] Running:
   [testng]   Ant suite
   [testng] 
   [testng] log4j:WARN No such property [maxFileSize] in org.apache.log4j.DailyRollingFileAppender.
   [testng] log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFileAppender.
   [testng] 2017-10-08 09:11:24,895 [main] INFO  org.automateit.example.test.DataTests - Excel data for data set id: data_set_id_1|Hello
   [testng] 2017-10-08 09:11:24,895 [main] INFO  org.automateit.example.test.DataTests - Excel data for data set id: data_set_id_2|Friday|Monday|Saturday
   [testng] 2017-10-08 09:11:24,896 [main] INFO  org.automateit.example.test.DataTests - CSV data for data set id: data_set_id_1|Hello There
   [testng] 2017-10-08 09:11:24,896 [main] INFO  org.automateit.example.test.DataTests - CSV data for data set id: data_set_id_2|Tuesday|Monday
   [testng] 2017-10-08 09:11:24,896 [main] INFO  org.automateit.example.test.DataTests - Pipe Delimited File data for data set id: data_set_id_1|Goodbye|Sayonara
   [testng] 2017-10-08 09:11:24,896 [main] INFO  org.automateit.example.test.DataTests - Pipe Delimited File data for data set id: data_set_id_2|Saturn|Earth|Venus|Mars
   [testng] 
   [testng] ===============================================
   [testng] Ant suite
   [testng] Total tests run: 3, Failures: 0, Skips: 0
   [testng] ===============================================
   [testng] 

BUILD SUCCESSFUL


So here are the contents of the files and then we show the little bit of java code that accomplished this task.



And here is the code:

Object declaration:

         protected Utils utils = new Utils();
    
    protected DataDrivenInput xlsInput = null;
    
    protected DataDrivenInput csvInput = null;
    
    protected DataDrivenInput pipeDelimitedFileInput = null;
    
    public static final String DATA_SET_ID_1_NAME = "data_set_id_1";
    
    public static final String DATA_SET_ID_2_NAME = "data_set_id_2";

Initialization:

         xlsInput = setupDataDrivenInput("data/example.xlsx");
            
    csvInput = setupDataDrivenInput("data/example.csv");
            
    pipeDelimitedFileInput = setupDataDrivenInput("data/example.txt");

And data extraction:

csvInput.returnInputDataForDataIdAndColumnNumber(DATA_SET_ID_1_NAME, 1);
csvInput.returnInputDataForDataIdAndColumnNumber(DATA_SET_ID_1_NAME, 2);


That's it! That's all you need to know. Give it a try and let me know if you have any problems or have suggestions for improvement.



Saturday, October 7, 2017

Way too easy test automation example from AutomateIt! framework

If you have basic java programming skills, then you can automate tests for web and mobile applications using a test automation framework called AutomateIt!

The framework is easy to download and build. All you need is Ant and Java installed on your system, and you are ready to go. Nothing else is needed. All of the source code is open and free, and you can download it here:

https://github.com/SWAutoTester/automateit

To show how easy it is, I will show you an example.

The example is simple: It will open up a web browser and enter text into the Yahoo! homepage Search textfield.


1) After downloading the framework, open a terminal window command prompt and go to the directory that you downloaded the framework.

Now you can decide which browser you want to run the example on.There are examples for Chrome, Firefox, and Safari. You need to have the latest version of each browser installed to run the example.

If you want to test using a Firefox web browser:

2) and type "ant example_firefox"

or,

If you want to test using a Chrome web browser:

2) and type "ant example_chrome"

or,

If you want to test using a Safari web browser:

2) and type "ant example_safari"

You should see the browser appear and text entered into the search text field.

Now you can view the reports and see all of the great information the framework provides for you out of the box.

Open up a file browser and navigate to the "results/html/index.html" file and double-click on the icon. You should see this report appear:


From here you will see a very detailed report consisting of:


a) a sequence of framework/webdriver command list used to drive each test
b) screenshot from the web browser of the screen at the end of each test
c) screenshot from the desktop
d) Page loading performance times and graph

Here are the results that appear for the first two tests run:




Give it a try. If you have any problems, feel free to connect with me on LinkedIn and ask me a question or comment on this post. I will be happy to help you.