01-21-2016, 11:46 AM
Hi All,
I was writing a function to take create objects using descriptive programming.
I donno where i went wrong, but the object is not getting returned correctly..
Below is the code.. ANyone please help me on this
Public Function fnObjectWithDescriptiveProgram(strObjectMicClass, strObjectProperties)
On Error Resume Next
Err.Clear
'Declaring Description Create
Dim oDesc, DictObjectProperties, strPropertyValues, strProperties
Set oDesc = Description.Create
Set DictObjectProperties = CreateObject("Scripting.Dictionary")
If strObjectProperties <> "" Then
strPropertyValues = SPLIT(strObjectProperties, ",")
strProperties = Array("name", "html id", "html tag", "text", "innertext", "column names", "index", "alt", "image type", "file name", "all items")
For itr = 0 To UBOUND(strProperties)
If strPropertyValues(itr) <> "" Then
DictObjectProperties.Add strProperties(itr), strPropertyValues(itr)
End If
Next
End If
Select Case UCASE(strObjectMicClass)
Case "BROWSER"
oDesc("micclass").Value = "Browser"
Case "PAGE"
oDesc("micclass").Value = "Page"
Case "WEBBUTTON"
oDesc("micclass").Value = "WebButton"
oDesc("type").Value = "button"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBEDIT"
oDesc("micclass").Value = "WebEdit"
oDesc("type").Value = "text"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "EMAIL"
oDesc("micclass").Value = "WebEdit"
oDesc("type").Value = "email"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "PASSWORD"
oDesc("micclass").Value = "WebEdit"
oDesc("type").Value = "password"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBELEMENT"
oDesc("micclass").Value = "WebElement"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "LINK"
oDesc("micclass").Value = "Link"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "IMAGE"
oDesc("micclass").Value = "Image"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBCHECKBOX"
oDesc("micclass").Value = "WebCheckBox"
oDesc("type").Value = "checkbox"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBRADIOGROUP"
oDesc("micclass").Value = "WebRadioGroup"
oDesc("type").Value = "radio"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBLIST"
oDesc("micclass").Value = "WebList"
oDesc("select type").Value = "ComboBox Select"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
End Select
Set fnObjectWithDescriptiveProgram = Description.Create
fnObjectWithDescriptiveProgram = oDesc
End Function
I was writing a function to take create objects using descriptive programming.
I donno where i went wrong, but the object is not getting returned correctly..
Below is the code.. ANyone please help me on this
Public Function fnObjectWithDescriptiveProgram(strObjectMicClass, strObjectProperties)
On Error Resume Next
Err.Clear
'Declaring Description Create
Dim oDesc, DictObjectProperties, strPropertyValues, strProperties
Set oDesc = Description.Create
Set DictObjectProperties = CreateObject("Scripting.Dictionary")
If strObjectProperties <> "" Then
strPropertyValues = SPLIT(strObjectProperties, ",")
strProperties = Array("name", "html id", "html tag", "text", "innertext", "column names", "index", "alt", "image type", "file name", "all items")
For itr = 0 To UBOUND(strProperties)
If strPropertyValues(itr) <> "" Then
DictObjectProperties.Add strProperties(itr), strPropertyValues(itr)
End If
Next
End If
Select Case UCASE(strObjectMicClass)
Case "BROWSER"
oDesc("micclass").Value = "Browser"
Case "PAGE"
oDesc("micclass").Value = "Page"
Case "WEBBUTTON"
oDesc("micclass").Value = "WebButton"
oDesc("type").Value = "button"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBEDIT"
oDesc("micclass").Value = "WebEdit"
oDesc("type").Value = "text"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "EMAIL"
oDesc("micclass").Value = "WebEdit"
oDesc("type").Value = "email"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "PASSWORD"
oDesc("micclass").Value = "WebEdit"
oDesc("type").Value = "password"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBELEMENT"
oDesc("micclass").Value = "WebElement"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "LINK"
oDesc("micclass").Value = "Link"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "IMAGE"
oDesc("micclass").Value = "Image"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBCHECKBOX"
oDesc("micclass").Value = "WebCheckBox"
oDesc("type").Value = "checkbox"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBRADIOGROUP"
oDesc("micclass").Value = "WebRadioGroup"
oDesc("type").Value = "radio"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
Case "WEBLIST"
oDesc("micclass").Value = "WebList"
oDesc("select type").Value = "ComboBox Select"
For each item in DictObjectProperties
oDesc(item).Value = DictObjectProperties(item)
Next
End Select
Set fnObjectWithDescriptiveProgram = Description.Create
fnObjectWithDescriptiveProgram = oDesc
End Function