View
 

Automated TestCases for PhoneGap

Page history last edited by Rohit Ghatol 11 months, 3 weeks ago


 

Introduction to Selenium

Selenium is the famous Web Automation framework developed by ThoughWorks. 

 

Selenium started as a javascript which was automating the UI. This was the first version of Selenium (Selenium 1). Selenium 1 relied on testing using javascript in the browser, but quickly suffered from various problems including (Same Origin Restriction). 

It looks like the same Origin Restriction does not hold true for Applications like PhoneGap, since we load pages from the app itself, just that these page communicated with remote services (Please correct me here, Incase this is wrong, I am in the progress of concluding this)

 

This way using Selenium 1 Test Runner was quite easy in PhoneGap based applications.

 

Then came Selenium 2, which uses web drivers. Web Drivers drives the browser itself, a massive improvement on top of Selenium 1's Javascript based Test Runner.

 

 

 

Automation using Selenium 1 (Test Runner)

 

Automation Demo

 

Download the project

Download the source code of above project here

 

Code Flow

The idea was to use the Selenium's Test Runner to load a Selenium Test Suite. The Selenium Test Suite will include number of Selenium Test Cases (The old html based tables). Once Selenium's Test Runner starts running it starts to execute the Application under test using an embedded iframe.

 

I did modify the TestRunner file of Selenium (which was more horizontally spread) to make it vertical to fit on phone screen. Also, I move the iframe which showed the application (which was previously below) to on the top of everything else.

 

 

Automation using Selenium 2 (Web Drivers)

 

The Good news here is there are already Selenium 2 Web Drivers available for Android and IPhone. The bad news is that these are driving actual web browsers. These web drivers are run as different apk.

 

In order to test PhoneGap based applications using Selenium 2 we will need to do following

 

  1. Extract the framework from Android and IPhone WebDriver and change them to drive WebView (Guess IPhone already does this)
  2. The include the Framework as a part of Android and IPhone Project and deploy them
  3. Then write external test case in Java/Ruby/Python (Selenium RC testcases) to connect to the Selenium Web Driver inside the application to run them

 

Disclaimer - A lot need to be explored here. Feel free to add your point of view.