Micro Focus QTP (UFT) Forums
QTP: WebEdit : How to check if values in list are disabled. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: QTP: WebEdit : How to check if values in list are disabled. (/Thread-QTP-WebEdit-How-to-check-if-values-in-list-are-disabled)



QTP: WebEdit : How to check if values in list are disabled. - katdean - 07-26-2011

I am testing a form, where I randomly pick the value in a webedit box "address type".

Some values are disabled (greyed out) depending on what the user already has. (See attached for sample)

I am trying to find out how I can check if a value in the list is disabled because it seems that I am able to select the value even though it's disabled. This will cause a problem when saving the record.

Code below where i select the value randomly for the webedit box:

Code:
AddressTypeArray = Browser("Address: New - Microsoft").Page("Address: New - Microsoft").Frame("Frame").WebList("addresstypecode").GetROProperty ("all items")
CountAddressTypeArray= Browser("Address: New - Microsoft").Page("Address: New - Microsoft").Frame("Frame").WebList("addresstypecode").GetROProperty("items count")

Randomize
    AddressType = vbNo
    AddressTypeArray=Split(AddressTypeArray, ";")
    AddressType = RandomNumber (0,CountAddressTypeArray-1)
Wait 2
Browser("Address: New - Microsoft").Page("Address: New - Microsoft").Frame("Frame").WebList("addresstypecode").Select AddressTypeArray (AddressType)

Any help or advise would be appreciated.
Thanks!


RE: QTP: WebEdit : How to check if values in list are disabled. - rajpes - 07-26-2011

Post screenshot of 'spy on that list' with those items


RE: QTP: WebEdit : How to check if values in list are disabled. - katdean - 07-26-2011

I am new to QTP, how do I 'spy on' the list?
Can you give me a sample?

Thanks!


RE: QTP: WebEdit : How to check if values in list are disabled. - rajpes - 07-27-2011

Read
"Viewing Object Properties and Methods Using the Object Spy" from qtp help document

http://www.youtube.com/watch?v=JXzQsTSH32I


RE: QTP: WebEdit : How to check if values in list are disabled. - rajpes - 07-27-2011

Anyway i tried some rough dirty code,hope some expert will you give clean solution.

Code:
txt=browser("browser").page("page").weblist("select").getroproperty("innerhtml")
arr=split(txt,"</OPTION>")
set disabled_items=createobject("system.collections.arraylist")
for each i in arr
    if instr(1,i,"disabled")<>0 then
       disabled_items.add mid(i,instr(1,i,">")+1,len(i))
        end if
next

ai=browser("browser").page("page").weblist("select").getroproperty("all items")
set all_items=createobject("system.collections.arraylist")
ar=split(ai,";")
for each i in ar
    all_items.add i
next

for each i in disabled_items
    all_items.remove (i)
next

cnt = all_items.count
randomize
myvalue = int(cnt * rnd)

browser("browser").page("page").weblist("select").select(all_items(myvalue))

set disabled_items=nothing
set all_items=nothing