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"
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)