WORKING WITH QTP

TestEveryThinG

Check object is Visible OR Not on Web Page QTP

Posted by rajivkumarnandvani on December 21, 2009

Hi All,

Some times we have to  check that a object(WebElement) should not exist on the page. For this we use object exist = False  property but when we run the script it gets failed While object is not showing in the Page. We think that there is  something  wrong.

The reason behind why QTP  is giving this because object is present in the page but not visible means it not displaying while it exist in HTML code.

So for this we have to be understand the object property( object.currentstyle.display) there will be case some time object inherit the property from its parent or another parent element property to display in page. First we have to identify that object when it not showing/displaying in page.We have to check its display property

Display property value we can get through like this

rem disvalue

disvalue =Browser(“Google”).Page(“Google”).Image(“Happy Holidays from Google!”).Object.currentStyle.display

if disvalue =”block” then

print ” object not displaying”

else

print ” object displaying”

end if

like this(incase if object using display property from its  parent object )  we have to check by which element my object showing on page

Advertisements

8 Responses to “Check object is Visible OR Not on Web Page QTP”

  1. Logic said

    Hi rajivkumarnandvani,
    What if my page contains a Webtable and one of the cells in the table contains 5 blocks
    how can take the information from each of the blocks?

    it seems that the QTP returns only the information on the default block in the cell.
    How can I specify the QTP to go to a specific block in the cell?

  2. Hi,
    first of u have to add webtable in objectrepository after that u will find different method to get cell data like getcelldata , Getrows ,cellvalue(row ,column) like that just chect in help file of QTP for webtable.you will get all the method.
    let me know is that information cover ur requirement or not
    Best of luck

  3. Logic said

    Thanks for the fast response!
    I already have the table on the OR, the problem is that the certain cell has 5 blocks
    I’ll try to explain:
    I have a table with one row and 2 columns.
    Above that table I have 5 Tabs.
    Switching between the tabs will change the information in cell2 (because its divided to 5 blocks)

    |Tab1|Tab2||Tab3|Tab4||Tab5|
    | CELL1 | CELL2 |

    When I click on “tab2” I’ll have on cell2 x:

    |Tab1|Tab2||Tab3|Tab4||Tab5|
    | CELL1 | X |

    and so the function Table.GetCellData(1,2)will return X

    Now when I click on “Tab3” I’ll have on cell2 Y:

    |Tab1|Tab2||Tab3|Tab4||Tab5|
    | CELL1 | Y |

    The problem is that the function Table.GetCellData(1,2)will still return X and not Y

    When I use FireBug to inspect the cell I see that I have 5 Blocks That only one of them is active (Block3 for this example because we chose Tab3)

    How can specify the QTP to take the information from a certain block in the cell?

  4. Hi,
    I am not sure that as much i understand ur problem or not.We need to identified when we select the next tab which row/column get active so that we can get currentactive cell value .You can pass the value by changing the number of column Table.GetCellData(1,x) OR Table.GetCellData(x,1) here x is variable as per ur active/current data.

    Do one just send me (rajivkumarnandvani@gmail.com) the page source of ur web page that will be good for me to better picture of ur problem. ans send the snap shot along with it

    Waiting for reply

  5. Anonymous said

    Nice post. I tried to use the property “Object.currentStyle.display”. but it doesn’t seems to work for me always. So i found a workaround for this. I am posting that.
    I tried to findout the number of webelement objects inside the property and the for each webelement i searched the property “height”. if the height is not 0 then the webelement is visible else not
    Ex:
    Set obj = Description.Create()
    obj(“micclass”).Value = “WebElement”
    obj(“html tag”).Value = “TD”
    obj(“innertext”).Value = “XYZ”

    Set ChildObj = Browser(“ABC”).Page(“ABC”).ChildObjects(obj)
    numberOfObj = ChildObj.Count() -1
    For i = 0 To numberOfObj
    If ChildObj(i).GetROProperty(“height”)0 Then
    MsgBox “found”
    End If
    Next

  6. Thanks 🙂 good one.

  7. Anonymous said

    Thanks you its works for me 🙂

  8. tony said

    Thanks! “GetRoProperty(“height”) worked for me as well.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: