tags:

views:

40

answers:

1

Hi,

I am facing issues while using Exist method in QTP..As if i use Exist with If else then it is working fine...but if used directly then not working...

Ex:

Browser("Home").Page("Home_2").WebEdit("ctl00$uxMNJDefaultContentPlace").Click
Browser("Home").Page("Home_2").WebEdit("ctl00$uxMNJDefaultContentPlace").Set DataTable("mfgpartnumber", dtGlobalSheet)  ''#Read mfg# from datasheet

Browser("Home").Page("Home_2").Image("ctl00$uxMNJDefaultContentPlace").FireEvent "onmouseover"

Browser("Home").Page("Home_2").Image("ctl00$uxMNJDefaultContentPlace").Click 31,11
wait(15)

Browser("Home").Page("Shopping Cart").WebElement("$3.99").Output CheckPoint("Shoppingcart_subtotal")

Browser("Home").Page("Shopping Cart").Check CheckPoint("Shopping Cart_price_2")

''#Browser("Home").Page("Shopping Cart").WebElement("$3.99").Output CheckPoint("$3.99")

Browser("Home").Page("Shopping Cart").Image("ctl00$uxMNJDefaultContentPlace").FireEvent "onmouseover"

Browser("Home").Page("Shopping Cart").Image("ctl00$uxMNJDefaultContentPlace").Click 66,10
wait(5)

Browser("Home").Page("Edit Shipping Address").Link("Continue").Click
wait(5)

Browser("Home").Page("Order Shipping Method").Link("Continue").Click
wait(5)

Here i want to replace wait(_ to some another method like Exist to improve performance...

Can anybody help me to sort it out..,.

Thanks, Guddu G

+2  A: 

@guddu

Since you wait for the browser to load another page, use Browser.Sync where applicable.
If an object does not appear right after a page is reloaded, use .Exist method with a parameter.
Example:

boolRC = Browser("Home").Page("Shopping Cart").WebElement("$3.99").Exist(15)  

This way, you give up to 15 seconds for an object to appear. If the object appears earlier, your script moves on faster.
If the object becomes available for operating with a delay after it's appeared, use WaitProperty method, as @katmoon pointed out.

Finally, you can implement your own synchronization function with customizable parameters like event (appear/disappear, etc.), time-out, property to check...

Example: http://automation-beyond.com/2009/08/20/gui-object-synchronization-custom-function/

Thank you,
Albert Gareev
http://automation-beyond.com/

Albert Gareev
Thanks for answering..but Exist function is not working..donn know why?It is working only with if ,else
guddu
Can you provide more details how it's not working? Is it error message, or you don't see an effect you expect; what's written in the log?
Albert Gareev
Sir,it is just an error message related to Exist function...:(But if i put exist function in if else then it works:(
guddu
@guddu, you have to use the return value of `Exist` you can't just have it on a single line without doing something with the returned value (as in Albert's `boolRc = ...`). If Albert's answer doesn't solve the problem please specify what error you're getting and on what line.
Motti