Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statement with recovery scenerio
#1
Solved: 10 Years, 8 Months, 4 Weeks ago Question 
Hi,

I am very new to QTP and VB scripting. I have recorded a test that is to open an Oracle window. Sometimes the Oracle window opens and sometimes it does not. I was advised to "put an if then else statement to wait for the window. If the window does not appear you can have it run a recovery scenario which you can set to close all the windows and restart the script." I am not sure what I need to do to accomplish what is written above. Can anyone help???

Thanks!
Reply
#2
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi

If (Window().Exists(2)) Then
' Do all required actions
' Exists(2) -> here 2 is to make your script wait for 2 second, use as per your requirement
else
Exit Test
End If
Reply
#3
Solved: 10 Years, 8 Months, 4 Weeks ago
I added the below code around my code and I get an error message:
Run Error
The test run cannot continue due to a syntax error.
Invalid 'exit' statement
Line(1): "Exit Test".


I am not sure why it is saying line 1, the if then statement is on the 3rd line. Then I have all of my if it opens then do all of this code, then on at the bottom of my code I have:
else
Exit Test
end if
on lines 60 - 62

Any ideas?????
Reply
#4
Solved: 10 Years, 8 Months, 4 Weeks ago Wink 
Hi Marie,

Did you made the required changes(add the property of the window) in the code send by kavita?

Note: This case should be handled by using if-else. There is no need to implement Recovery scenario for it.

Smile
Reply
#5
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi Marie,


The syntax is "ExitTest" not "Exit test". There is no space.

Try this , it should work.

- Vinod
Reply
#6
Solved: 10 Years, 8 Months, 4 Weeks ago
Thank you! The ExitTest stopped the script from running right away. Now I am having an issue with the If part of the statement:

Code:
Browser("Oracle Applications 11i").Page("Oracle Applications 11i").Sync
Browser("Browser").Page("Oracle Applications").Sync

wait(30)

[color=#FF0000]If (Browser("Oracle Applications 11i").Page("Oracle Applications 11i").exists(2)) Then[/color]
'if the Oracle window opens then run the rest of the test
else
ExitTest
End If

I get a run error message:
Object doesn't support this property or method:
Code:
'Browser(...).Page(...).exists'

Line (7):
Code:
"If (Browser("Oracle Applications 11i").Page("Oracle Applications 11i").exists(2)) Then"
Reply
#7
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi,

The Syntax is wrong again,

The correct syntax is "Exist" . It is not "Exists"

try the below code

Code:
If (Browser("Oracle Applications 11i").Page("Oracle Applications 11i").exist(2)) Then
'if the Oracle window opens then run the rest of the test
else
ExitTest
End If


- Vinod
Reply
#8
Solved: 10 Years, 8 Months, 4 Weeks ago
Thank you, this part now seems to be working great!

My only problem now is the fact that I am exiting the test instead of restarting it. Other tests are based on this one running, so if it doesnt open the window the first time I need it to go back and try again until the window opens and the rest of the test can finish. Is there a restart instead of an exit??
Reply
#9
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi Marie,

There is no Restart. You can increase the wait in the Exist, for example if give Exist(100), the script will wait 100 seconds and if the window appears before 100 seconds, the If condition will be sucussful and the next line of code is executed.

This should solve the problem.

Thanks
Vinod
Hi Marie,

Instead of restarting the script, you may use the below script,

Code:
URL = "www.google.com" ' Enter URL of the Application
' Open the Browser and navigate the URL
SystemUtil.Run "IExplorer",URL

Do

If Not Browser("Oracle Applications 11i").Page("Oracle Applications 11i").exist(30) Then
   ' If the Window is not displayed  close all the browsers
   SystemUtil.CloseProcessByName "Iexplore.exe"
   ' Open the Browser and navigate the URL
    SystemUtil.Run "IExplorer",URL
  Else
   ' If the Window is  displayed  then ExitTest
    ExitTest
End If
Loop

Let me know if this works for you..

Thanks
Vinod
Reply
#10
Solved: 10 Years, 8 Months, 4 Weeks ago
Vinrod,

do I call this script from within the script I already have? I am a little confused by the ExitTest, wont that kick me out of the test instead of running the rest of what I have?

Thanks!

-------------------------------------------------------------------------------------------------------------------
I am guessing I did this wrong based on the fact that I now crash my script by adding the new script into the working one.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  recovery elsekra 0 1,321 12-19-2008, 12:34 AM
Last Post: elsekra

Forum Jump:


Users browsing this thread: 1 Guest(s)