Tuesday, June 30, 2009

What Is New With DynamicDOM 2.0

While working with initial version on DynamicDOM, I was thinking that this Framework should work completely independent to achieve its objective to provide Easy, Simple though reliable automation framework which should have ability to work with pure VBScript.

As we all know that DynamicDOM 1.0 was purely Dom based Framework and DOM is a native API of Web Browser reason DOM does not support window objects and dialog box, though many times I faced questions from DynamicDOM users, about how to handle JavaScript and VBScript’s dialog box alert/confirm/prompt/MsgBox/InputBox.

I used to tell them in that case you need to use this framework with QTP/ Rational/ AutoIT or other similar platform, which support this functionality and you can utilize DOM’s control identification Mechanism.

But those questions made me think twice, if I can add dialog handling functionality in our DynamicDOM, it will make life really easy.

To run most of the OpenSource WebTesting application, require huge frameworks which all are needs to be installed first like JAVA, RUBY and some Require PYTHON. At the same time DynamicDOM does not require any third party assembly, code, compiler or application to work for WebTesting in windows with dot net framework.

DynamicDOM 2.0 can efficiently handle all types of dialog box while working with web application.

DynamicDOM 2.0 is completely new, now DynamicDOM can do a lot more for you

Features 2.0:

  • · Added Direct JS execution Method (for JavaScript testing)
  • · Synchronies Functions Wait(Seconds) and Object Sync Methods
  • · Added extended dialog handling support (mydialog.Click, mydialog.GetText)
  • · DynamicDOM 2.0 can now Work with multiple browsers simultaneously (CreateBrowse, GetBrowser)
  • · Browser State handling support (minimize , maximize, restore)
  • · Close single browser, close all browser
  • · Return type Enhancement ArrayString to Array, now DynamicDOM directly return data in array.

Features 1.0:

  • · DynamicDOM is a win32 COM, so its support many windows based programming languages. VBscript, Visual Basic 6, visual C++, C#,J#, VB.net and many more
  • · It Works with Open source language such as Ruby as a win32ole object, python, and many others.
  • · It has no UI, and can be used by developers for there web automation tool development.
  • · It is free for commercial use (Please read license teams)
  • · DynamicDOM is the most compelling alternative [to Fit] for filling the automated acceptance testing need.

Thursday, May 7, 2009

DynamicDOM V 1.0 Is Here

DynamicDOM is an open-source library for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible.
DynamicDOM drives browsers the same way people do. It clicks links, fills in forms, and presses buttons. DynamicDOM also returns results, such as whether expected text appears on the page, form controls, in the tables and grids.

Features:
  • DynamicDOM can work with any language on windows and can incorporated with any tool, it currently supports Internet explorer. We can use DynamicDOM with VBscript, VB6, .Net.
  • Works Open source language such as Ruby as a win32ole object, python, and many more.
  • It has no UI, and can be used by developers for there web automation tool development.
  • It is free and it is OpenSource
  • DynamicDOM is the most compelling alternative [to Fit] for filling the automated acceptance testing need.


Register DynamicDOM.dll
Regsvr32 \DynamicDOM.dll


Quick Example

Set Dom = CreateObject("DynamicDOM.Application")
Dom.AUTSettings "http://www.google.com"

Dom.DomAction "name=q","set","Mad4Test"

Dom.DomAction "name=btnG","click"



Wednesday, May 6, 2009

Dynamic DOM White Paper (Working Draft)

Object Identify Methodology

DynamicDOM is purely DOM based selectors, which uses native DOM functionality using inbuilt windows libraries, so it does not actually work other then internet Explorer but powerful enough that it also does not require any object identification functionality using QTP OR/DP or any other object spy tools

Moreover it has no repository and does not store any physical property in form of db, txt, xls or xml.

Core DynamicDOM Engine.

In modern Web Development Environment there are many user libraries, and selectors which can efficiently work in client side scripting, but the problem with them is difficulties to understand, extensive code, performance issues DOM, conflicts to the AUT’s native functionalities mainly those are not developed for web automation testing.

Whereas DynamicDOM is created by keeping Testing as a main Objective in mind, it is very simple and logical to understand, thought extensive to cover most of the actions.

DynamicDOM Selectors are influenced from xpath and derived from JQuery’s selector Slizer, extjs and Dojo and written from the scratch.



Getting Started:

DynamicDOM is win32 COM objects like other windows object, it has no external framework dependency to create instance of DynamicDOM object

Dim Dom

Set Dom = CreateObject("DynamicDOM.Application")



API Methods


1) AUTSettings(ByVal PageObject, [ByVal SenderApp As String])

2) DomAction(ByVal oCtrl, ByVal oEvent, [ByVal oValue As String]) As String



AUTSettings

This is required function to initialize settings. AUT settings needs to be called first before using DomAction Method calls

Parameters


PageObject (Required): Page object is depending upon senderApp parameter if we are using DynamicDOM from QTP we can send page Object stored in Object Repository, QTP DP or DynamicDP’s object, also if we do not want to use QTP’s Objects we can directly pass URL to be opened.

Set oPage = Browser("TestForm").Page("TestForm")

Dom.AUTSettings(oPage,"QTP")

OR

Dom.AUTSettings(“http://www.google.com”)

SenderApp (Optional): if we want to use QTP page Objects stored in Object Repository, QTP DP or DynamicDP’s object, we need to specify SenderApplication Name as “QTP” (String), by Default it is non-QTP dependent.



DomAction:

Once we initialize application using AUTSettings we are ready to perform actions using DomAction Method.

DomAction method required three parameters, 1st one is object location at DOM, 2nd is the Event/action which we wanted to perform and lastly Get and Put Values which is again optional for some actions.


Working with DynamicDOM on WebApplication:

Using DynamicDOM we can utilize object name, id, class and tag to navigate object in DOM Three.



E.G.

Sending location without Array index

Name=btnG

Name=r1



The above code style will navigate to all control which is having Name “btnG”, it also return an Array String having Pipe “|” as unique separator if user with Event “Get”.



Sending location with Array index

Name=btnG[0]

Name=r1[3]



Name=btnG[0] will locate to 1rd control having name called “btnG”, and 3rd control with name “r1”. Same like name we have “id” this is “html id” and it does not require Array Index, it has been assumed that every page has a unique html id.



Some More example of Control selectors

id=mybutton

Select object having id mybutton

name=btng[0]

Select object having name btnG and index 0

name=r1 [3]

Same as above with index 3

name=r1

using its “name” (Array String)

class = mydropdown

using its “Css Class name” (Array String)

class=odd [1]

Select object having Css class odd and index 1

class=even [8]

Same as above with index 8

tag=input

html tag as “Input”

tag=input>text

html tag as “Input” and type as “text”

tag=input>text[1]

single object which has index 1

dom=span

Uses dom addressing method of selecting object, select all “span html tag” (Array String)

dom=.odd

Dom addressing on css class basis

dom=#mybutton

Using ID

Dom=div#main>p.external

This will return an array containing all of the links that have “external” in their “class” attribute and are contained inside a paragraph which is itself contained inside a div with its “id” attribute set to “main”.

Dom=div>table>td.odd

Td with class name odd in the given hierarchy

Dom=a[href^=http://www]

Using some regular expressions (^for starts with)

Dom=a[href$=org/]

$ ends with

Dom=a[href*=google]

* anywhere

Dom=a[rel=bookmark]

Exact match

Dom=a[title]

All anchor who has title attribute



* Array String = Returns pipe separated String and can be converted to array using split



Events (oEvent)

Basically there are three operations which DynamicDOM does

1) Setting Values (Set)

2) Getting Values (Get)

3) Selecting Controls (Select)

4) Clicking Controls (Click)



Every event depends on value parameter, though it is not compulsory in case of “Click” event, user needs to be a bit logical while using events with values (oValue), and understand what will be the return type, String, Array String or Void.



Usage

Events

Values

Comments

Set

String text

It will automatically find innerText or Value depending upon textbox or webelements

Get

innerText

This is not case sensitive, but for general practice we should try to be habituated (returns innerText)

innerHTML

Returns innerHTML

value

Returns Values

Select

#and indexnumber

Selects on the basis of index (Only for dropdown not for Radio/checkbox)

$ and value

Selects on the basis of its values

“visible text”

This is innerText visible text of dropdown

Click

[Optional value]

Click object having this value


Adding all together.

Dom.AUTSettings "D:\javascriptinggetValue5\testform.html"

Dom.DomAction "id=Check2", "click", ""

Dom.DomAction "id=mybutton", "click"

Dom.DomAction "tag=input>text", "set", "Have a Good Day!"

Dom.DomAction "tag=input>text[1]", "set", "Good Morning!"

Dom.DomAction "id=textbox2", "set", "DynamicDOM is Cool"

Dom.DomAction "id=dropdown1", "select", "C"

Dom.DomAction "id=dropdown1", "select", "#3"

Dom.DomAction "id=dropdown1", "select", "$one"

Dom.DomAction "name=s1[1]", "select", "$4"

Dom.DomAction "dom=span", "click"

Dom.DomAction "name=t1[3]", "set", "This is a Nice Day!"

Dom.DomAction "name=t1", "set", "All t1 have same data"

MsgBox Dom.DomAction("tag=input>text[1]", "get", "value")

MsgBox Dom.DomAction("tag=input[7]", "get", "value")

MsgBox Dom.DomAction("tag=select", "get", "count")

'--------------------------------------------

MsgBox Dom.DomAction("tag=input>text", "get", "value")

MsgBox Split(Dom.DomAction("tag=input>text", "get", "value"), "|")(1)

'---------------------------------------------

MsgBox Dom.DomAction("name=s1", "get", "count")

MsgBox Dom.DomAction("id=textbox2", "get", "value")

MsgBox Dom.DomAction("class=odd[0]", "get", "innertext")

MsgBox Dom.DomAction("class=odd[1]", "get", "innerHTML")

MsgBox Dom.DomAction("class=odd", "get", "count")

'---------------------------------------------

Dom.DomAction "name=r1", "click", "val3"

Dom.DomAction "name=r1[0]", "click", ""

Dom.DomAction "id=Check2", "click", ""


That’s All!

Folks, Downloads are still not there because DynamicDOM 0.9 COM component is still under final whitebox, and will be there within this week.

Please contact me anyone interested for BETA Testing


Tuesday, April 21, 2009

DynamicDOM coming soon...

Modern software techniques and continuous revelations to the browser’s web rendering engines and DOM manipulation libraries, took website development to the new era. Working draft of HML 5.0 brought many new features to legacy markup language itself.

I being a member to the Automation community, many a time I faced questions from others regarding difficulties in getting the objects to perform test operations. Well there are many reasons why automation tool’s Native functionality sometimes really can’t help. Modern UI frameworks transforms simple web elements/controls to a rich looking controls and add extra functionalities e.g. using rich UI framework (javascript and css) converting a simple html select to Ajax autocomplete dropdown.

Sometimes People claims that there are no property which can be used to identify an objects,
Others asking me QTP doesn’t works with objects depending upon it runtime object properties or, WebRadioGroup is one of the examples which doesn’t works with “html id”.
QTP does identify objects depending upon its logical Test-Object Properties

Performing actions to multiple objects stored in object array is also not possible with automation tools without looping through array length. This increases code length, development time and increases script maintenance costs. Sometime it is also very difficult to guess how QTP will be going to behave with particular objects to identify there logical name which will help users to map there objects using Descriptive Programming in advance.

On the contrary DOM reads multiple objects having the same object properties and attributes and keeps them it into the array.

E.G.
getElementsByName
getElementsByTagName
getElementsByClassName (userdefine)
getElementsByRegExp (userdefine)


Advantage of DynamicDom.

DynamicDom directly uses Dom to work with AUT, as soon as the user send command to Dom using domAction function, the framework elaborate function depending upon its parameter and create a dynamic Local method in Dom.

  • DynamicDom returns results as a string (Array v1.1, objects v1.2, object array v1.3)
  • DynamicDOM works locally to DOM so it avoid clashing AUI’s Native resources (functions/class/variables)
  • Logs actual DOM generated errors, helps users to debug there code.
  • Everything works under try-catch so it does not affect AUT’s functional structure.
  • True synchronization working with Ajax and testing ajax based application. (upcoming article on DynamicAjax with DynamicDOM)
  • DynamicDOM can do more and other things and Fastest way to work with objects comparison to OR and DP.
  • Tool independent framework (version 2.0)
Donwload is coming soon... so be connected :)



Monday, April 20, 2009

DynamicDP Gone Wild!

I am glad to publish some statistics of my blogs visits and download counts of this week...

Last 10 days Visits counts: 878
Last 10 days downloads so far: 375

Last week Activity:

• Roger Douglas contributed to the script which will be integrated after some more testing.
• DynamicDOM is almost completed and, it is under testing, will release in this week as soon as I complete its user notes.

Below images is showing all users from enterprise who have downloaded and using DynamicDP to there projects...


Tuesday, April 7, 2009

Dynamic DP


Working as a Test automation engineer from last few years using various technologies with an Open source Attitude, I have always tried to develop reusable components which will help user to reuse there efforts and can be easily maintain and optimize test running.


While working with Quick Test Professional® I found they have very good concepts of Object repository which contain physical properties collections of object to identify it easily.
QTP being following Microsoft methodology of making user friendly UI, so they have provided an interface which can be used to create objects which can be used at runtime.


“Another example of there UI holiness is “keyword view”. I myself don’t understand how does it really works, better if they would have spent some more time on providing useful features like batter auto-complete with batter IntelliSense, code region (code collapse), multiple test development interface”



Object Repository is a wonderful feature and helps while working with some static, type’s objects but while working with dynamic (run-time) objects their main identification properties are dynamically updated, which creates cumbersome in managing tests. But QTP again have wonderful Solution to that, which we all known as “Descriptive programming”.

Descriptive programming (DP), as it is named, it does the same work, while working with this, user just needs to provide attributes values of there objects, to “description” class which is having only single public method called “create”.

DP is easy to use but it increases the lines of codes, again it has comparatively slower execution then precompiled object repository. While Working with DP I also found problem of “QTP loses its web object reference” on navigation /Post back. Which also have been faced by a large QTP community while working on different applications. But for a complex and large size application DP is the best approach which can be used.



"There are many articles already present for DP saying its advantages and disadvantages, and its needs, so let’s do not to reinvent wheel."



How effectively use DP
This white paper is containing a DP approach which will identify How to solve DP related issues, it also have a batter object definition structures which helps to code fast and optimized why with easy maintainability and provide flawless execution, which is a robust system and allow users to play with the Objects on the fly.

CodeName : DynamicDP 1.0
While working with QTP from long time and being connected to community I have seen many experts are creating dynamic objects outside the QTP, to achieve this they use xml, some use CSV (bad idea) but most of them uses excel spreadsheet which is more reliable and can be queried directly using FSO cell reference or by ADO connection.

Some time back I had a talk with a quite senior community member asking how you use your objects in your framework in a forum thread. Unexpectedly after a couple of days I got an email with an attached excel sheet screenshot and found that addressed forum member shared his idea with me. He was keeping those objects properties in excel sheet and creating object dynamically.
Okye, but it wasn’t so great manually managing those big sized excel sheet and its maintenance, but somehow replacing OR for that framework didn’t impressed me more.
This initiated a thought to have something which uses even better approach to carry objects and have a strong reason to use it.

Dynamic DP is a GUI application which works on MSHTA and uses internal explorer internally, it is made on javascript, vbscript , html and external third party library like jQuery and a jQuery treeview, context menu, thickbox plugins. It has a similar front end similar to OR (more UI part needs to be added) .

By Double clicking DPTree.hta it will popup same like screen 1 without tree nodes.



Screen 1


Clicking on root node it will appear a Thickbox which has “Parent ID” = 0, normally a browser object like Screen2.



Screen2




New objects can be stand alone without parent objects and while using those object we can provide parents to it.



ones object gets saved it will appear under root node. right click will open a context menu currently three options are displayed, ADD , EDIT and REMOVE



Screen 3


Once object get saved can click (normal left click) on it to fill its description.





All done ! now we are ready to use these dynamically created object.


How do we use dyamicDP in our Test


The First Step
'this is required statement and it should come on the top of the user action
ObjCollection.BuildObjTree()

Working Set
'============== ways of Using Objects ===============
'Using objects Style 1 [MyObjID + Ctrl keyword]
myBrowserCtrl.highlight()
myPageCtrl.highlight()
myWebEditCtrl.highlight()

'Using Objects Style 2 [MyObjID as a DP object]
Browser(myBrowser).highlight()
Browser(myBrowser).page(myPage).highlight()
Browser(myBrowser).page(myPage).WebEdit(myWebEdit).highlight()

'Using Objects Style 3 [Mixed Approch]
myPageCtrl.WebEdit(myWebEdit).highlight()
'=============================================

'=================== Some Invalid ways it will produce error ===========================
myPageCtrl.myWebEditCtrl.highlight() 'Error
' myWebEditCtrl is Already a Qualified Control and its Parents is Already decidede
' but the same control can be used as A [MyObjID as a DP object] which is stated above even for the other parents.
'===================================================================================


while Creating Object we have to BE CAREFUL selecting the Object Name
if we use the same object Name for other or New object the System will overwite it




Functional Reference

'******************************************************************
'**** ObjCollection.BuildObjTree()
'**** ObjCollection.UpdateObj(ObjName, propName, propVal)
'**** ObjCollection.CopyObj(NewObjName, ObjName, ObjParentName)
'**** ObjCollection.RemoveProps(ObjName, propName, propVal)
'**** ObjCollection.AddObj(ObjParentName, ObjName, ObjType, ObjDesc)

'******************************************************************

'this is to build three.
GoogleCtrl.highlight()
GoogleCtrl.sync 'I try always try to add sync in my AUT test framework

ObjCollection.UpdateObj "Link1","innertext","About Google"
Link1Ctrl.highlight() ' it will click About google link
GoogleCtrl.sync

ObjCollection.CopyObj "Link2","Link1","GooglePage"
Link2Ctrl.highlight() 'it will create another link with name Link2 and will do the same opration which can be done by Link1


ObjCollection.RemoveProps "Link1","innertext"
ObjCollection.UpdateObj "Link1","name","Privacy"
Link1Ctrl.highlight() 'it will open "Privacy" link but using different object identification properties


SearchTextboxCtrl.set("Manish Bansal")
SearchButtonCtrl.highlight()

ObjCollection.AddObj "GooglePage","Radio1","WebRadioGroup","name=meta"
Radio1Ctrl.select "#1"

'******************************************************************

Integration
Please go through Read me file shipped along with core.

Get DynamicDP 1.0

Download Link



Happy Automation :)








StatCounter