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= | 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
hey nice tricks, waiting for downloads...
ReplyDelete-Edmond