Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check object existing or not?
#1
Not Solved
Hi all,

I have this case as:
- Select country that has states, the State drop down is displayed
- Select country that does not have any states, the State drop down is not displayed.
i use the command to check as: rc = Browser("OSS").Page("ManageCustomer").Frame("CustomerDetail").WebList("ddlState").GetROProperty ("disabled").
But the return value of rc is always '0'.
I tried get visible property but the return value is always 'True'.

So i want to ask is there any way to check this case?

Thanks,
linhke


Attached Files Image(s)
   
Reply
#2
Not Solved
Hi,
This is because the WebList is not disabled if there are no states. Use:
GetROProperty("items count")
Reply
#3
Not Solved
Thanks for your answer,
I have the same with the message, it is a WebElement. When click OK button on the message, it's dismissed but QTP still can get all the property of it with the same value when the message is displayed. So i can not find the way to check it dismissed or not.

Thanks,
linhke
Reply
#4
Not Solved
Hi,
You will have to use GetROProperty("items count") on State weblist everytime you change the country. If there are options available in state weblist, items count will be greater than 1 and if there are no states, it will be 0.
Reply
#5
Not Solved
Thank Manish, i know that.
I want to ask the solution to check the message object (it's a WebElement) as i mentioned above.

Many thanks,
linhke
Reply
#6
Not Solved
Please provide more details of your message webelement, snapshot and properties..
Reply
#7
Not Solved
The message is the image, and the properties of it are: innertext, outertext, visible, ...
I tried check the property 'Visible', but it is always True during the message is displayed or not.
Thanks,
linhke


Attached Files Image(s)
   
Reply
#8
Not Solved
Hi,
well u can use the "Exist" property of QTP
Code:
if obj.exist the
msgbox "true"
else
msgbox "false"
end if

hope this helps u.

regards,
Amit
9773539313
Reply
#9
Not Solved
Hi Amit,

I tried your way but the return value is always True, although the Message is not displayed.

Thanks,
linhke
Reply
#10
Not Solved
Typically these types of dialog boxes are WebElements using DIV tags. Also, they typically are not actually hidden when not shown, which is why the visible and exist always return true. The trick is that their dimensions are set to 0. If you are able to identify the DIV that represents the dialog box (which it sounds like you have done), you can test the width and height of the WebElement to determine if it is visible or not. Something like:

Code:
If Browser("").Page("").WebElement("").GetROProperty("width") > 0 _
          And Browser("").Page("").WebElement("").GetROProperty("height") > 0 Then
MsgBox "Dialog is visible!"
End If

I use Firebug (with Firefox) to inspect the HTML of the pages I'm testing to determine the DIV structures in situations like this. It's as easy as right-clicking and selecting "Inspect Element." Firebug has really been a great help to me when trying to figure out issues like these. IE has the Developer Toolbar that has similar functionality, but is not as nice. Check them out!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Check Object Spacing goaliema3026 0 1,609 06-25-2015, 01:10 AM
Last Post: goaliema3026
  Code not recognising Browser object as existing brigna 0 1,717 12-04-2014, 08:32 PM
Last Post: brigna
  Qtp can not identify existing script prit deo 0 1,797 03-03-2014, 04:23 PM
Last Post: prit deo
  Need to embed worksheet to already existing excel mahaktikoo 1 2,315 09-27-2012, 12:13 AM
Last Post: krr
  How to identify the object reference to the existing(already opened) Excel sheet yogeesh 1 9,772 09-26-2012, 07:00 PM
Last Post: krr

Forum Jump:


Users browsing this thread: 1 Guest(s)