Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checkig color of an image???
#1
Not Solved
Hi all,
This is an intresting challenge I got but I am unable to make a move.

Please have a look at my attached image.
My requirement is this : If I have to select any of the records (listed in the image with checkbox each ) between any specific time period - example from 1/15/2010 to 1/30/2010 - I should only select a record which has the color green (This is the color set to a vacant record - can be seen in the legend below : Green implies vacant) with in the time period specified.
so while automating how do I check that which record has the same color as that of the legand 'vacant'??

Do I have to use a bitmap checkpoint ?? but that didnt wrk for me either.

any way to go ??

Please help.

Thanks
Swetha


Attached Files Image(s)
   
Reply
#2
Not Solved
what is object there which is having color, can you paste the spyshot?

Reply
#3
Not Solved
Hi saket ,

Here I have attached the spyshot of the object in the grid with colors. QTP is recognizing each small cell with color as one element.

Thanks
Swetha


Attached Files Image(s)
   
Reply
#4
Not Solved
ok, Thats great
use '.Object.currentStyle.backgroundColor' to get the background color of your element in each cell.

Reply
#5
Not Solved
HI Saket,

I got a small doubt here... Using 'Object.currentstyle.backgroundcolor' we can get the color of that Object... But, as per the question. how can we check any particular 'CheckBox' and selecting desired TimePeriod and get the Color of Cell...

Actually It is not identifying as a 'Cell' It is identifying as a 'WebObject'

Thanks
Reply
#6
Not Solved
D.Baba Fakruddin - do you have the same application at your side? or just wondering whether both of you are same Smile
what is not identifying as a 'Cell' It is identifying as a 'WebObject', as per swetha b its an webelemnt in her wetable?

I think the question is to get the row where there is Green in a certain time period.. so you just need to identify the column first depending on the time period, then in that column check the color of webelements in each row, if it matches with your criteria check the checkbox in that row of your webtable.

Reply
#7
Not Solved
Hi saket,

Thanks for your response. Now I could abe to get the color of a cell using the code you have given:

Code:
var = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebElement("WebTable").Object.currentStyle.backgroundColor

Now the issue is : as baba mentioned (btw we are not same Smile) I have to choose those columns with the specified time period and compare each cell color in the row (within the specified time period) with the legend (Vacant : Green).

Issue is how do I select those columns : Please have a look at the attached screen shot which shows how the column names are divided and number of cols.

Did I make sense ??


Attached Files Image(s)
   
Reply
#8
Not Solved
As I can see in the snapshot the columns does not include the subcolumns there which is 0,1,2,3,.. it is representing it as the main column which is Jan2010,..
I beleive all the webelements are in the columns, can you check it if you can get all the elements in a particular column lets say 7th column
if you are getting this check each elements color in a cell, numerise it as per index (to identify the time period) and do the required.

Let me know how it goes.

Reply
#9
Not Solved
Hi Saket

Here I go , lot many questions and lot many doubts :

Looking at your reply I have tried these combinations. But nothing seems to be working properly:

1) Using Child Object mthod:
Code:
Dim obj_checkDesc, allchkvalues, singlechkvalue
[i]'Webelement description object[/i]
Set obj_checkDesc = Description.Create
obj_checkDesc("html tag").value = "TD"
obj_checkDesc("height").value = "23"
[i]'using the class name as object is in theChidItem Method[/i]
For i = o to 5
set a = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2").ChildItem(2,7,obj_checkDesc, i)
msgbox a.currentStyle.backgroundColor
Next
The above statement throws me an error


2) Using descriptive programming
Code:
i= 2
[i]'Checking the existance od checkbox in each row [/i]
Do While Browser("TalonPro Solutions").Page("TalonPro Solutions_2").WebCheckBox("html tag:=INPUT","type:=checkbox", "index:="&i).Exist

[i]'Checking the webelement in each column [/i]
For j = 5 to columcount
    objcolor = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2").webelement("html tag:=TD","height:=23","index:="&j).Object.currentStyle.backgroundColor
    msgbox objcolor
     If  objcolor <> vacantcolor Then
         Exit for
         else

     End If
[i]'Check box checked after ecah column check[/i]
     Browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2").WebCheckBox("html tag:=INPUT","type:=checkbox", "index:="&i).set "ON"
Next
The above code works fine . But, it checks all the checkboxes irrespective of the color mismatch.

3) Getting Child Object
Code:
Dim obj_checkDesc, allchkvalues, singlechkvalue,objcolor
Set obj_checkDesc = Description.Create
obj_checkDesc("html tag").value = "TD"
obj_checkDesc("height").value = "23"
obj_checkDesc("outerhtml").value = ".*BORDER-RIGHT: 1px solid.*"

[i]'used this to get the child objects [/i]
Set allchkvalues = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2").ChildObjects(obj_checkDesc)

[i]'Webelement count [/i]
countweb = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2").ChildItemCount(5,8,"WebElement")
msgbox countweb

[i]' countweb: This always shows '0' value[/i]

For  i = 0 to countweb

objcolor = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2").webelement(obj_checkDesc,"index:="&i).Object.currentStyle.backgroundColor
msgbox objcolor
Next
Please guide me which approach would be helpful and how to go with it ???

Thanks
Swetha
Reply
#10
Not Solved
Hi Swetha,
Sorry for my ignorance if I didn't go through your scripts properly.
I would like to suggest you a different approach here
Code:
ObjTable = browser("TalonPro Solutions").Page("TalonPro Solutions_2").Frame("Frame").WebTable("Property_2")

With ObjTable
        RCount = .RowCount    
        bFnd = false
        For RCntr = 1 To RCount
            CCount = .ColumnCount(RCntr)
            For CCntr = 1 To CCount
                ItemCount = .ChildItemCount(RCntr, CCntr, "WebElement")     
                For iCnt = 1 to ItemCount
                        Set objWE = .ChildItem(RCntr, CCntr, "WebElement", iCnt)
                        sColor = objWE.Object.currentStyle.backgroundColor
                        If sColor = Color of the vacant element Then
                            'Check the checkbox on that row
                            bFnd = true
                            Exit For
                        End If
                Next
                If  bFnd = true Then Exit For
                
            Next
            If  bFnd = true Then Exit For
        Next
End with
can you try this and let me know if it works for you?

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with Text color recognition Treirk 0 983 06-17-2019, 12:19 PM
Last Post: Treirk
  Getting background color of an object on mouse over Surya 2 3,721 06-27-2018, 08:51 PM
Last Post: vensas3181
  How can we get the Windows application Text box background color Using UFT 11.53 Kuppampattu 3 5,683 06-06-2017, 11:12 AM
Last Post: workrohit08
  SwfTreeview - Color validation for child item YogeshCallappa 0 2,072 11-10-2016, 04:55 PM
Last Post: YogeshCallappa
  how to get background color of a WinButton javierchen 1 2,901 03-17-2015, 10:59 PM
Last Post: babu123

Forum Jump:


Users browsing this thread: 1 Guest(s)