How to detect title of dialog first then only decide which script to be executed? VBScript
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to detect title of dialog first then only decide which script to be executed? VBScript
Hi, I'm using TestComplete11 with VBScript. My situation is I have a desktop application which is RobotArm and it developed into 32bit and 64bit.
The RobotArm(x32) has the starting dialog named "MAIN PAGE" with button "SKIP", while RobotArm(x64) has the starting dialog named "Home" with button "Skip".
My scirpt can work well for both version but when the software is loading slow, the script will be executed and ignored the dialog when it came out after that.
Can TestComplete detect the dialog title first and then decide which line to be executed? As I know TestComplete execute the script line by line. I tried to use 'Select Case' method but it got error.
My purpose is the script can be applied for both x32 and x64 application. The vbscript is shown as below. Thanks for any suggestion.
sub InitialDialog set w=sys.Process("RobotArm").WaitWindow("#32770", "MAIN PAGE",-1,1000) set w1=sys.Process("RobotArm").WaitWindow("#32770", "Home",-1,1000) if w.Exists then w.Window("Button", "SKIP", 1).Click elseif w1.Exists then w1. Window("Button", "Skip", 1).Click else end if end sub
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What you have is pretty good code for what you want. However, your time out (currently set to 1000) may not be enough. I'd bump that up to something like 10000 if your application takes longer than a second for the dialog to appear.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had tried to increase the waiting time but if I applied the script on the 64bit application, I have to wait the 10 seconds to pass as the "HOME PAGE" won't appear.
Is there any method to avoid this? That can make the script more efficient. Thanks.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
EVery process has a propery called ProcessType. If it's 32 bit, this will have a value of x86, if it's 64 bit, this will have a value of x64.
So, you could rewrite your code like this.
sub InitialDialog set w=sys.Process("RobotArm").WaitWindow("#32770", "MAIN PAGE",-1,1000) set w1=sys.Process("RobotArm").WaitWindow("#32770", "Home",-1,1000) if Sys.Process("RobotArm").ProcessType = "x86" then w = Sys.Process("RobertArm").WaitWindow("#42770", MAIN PAGE", -1, 10000); else w = Sys.Process("RobertArm").WaitWindow("#32770", "Home", -1, 10000) w.Window("Button", "SKIP", 1).Click end if end sub
Side Note... investigate NameMapping. You can identify objects a LOT easier and a LOT more reliably when they are mapped. Your "Home" page could even be contingent mapping where the choices of how to identify it are built in so you don't even need to do the "WaitWindow".
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Another approach is to use a code like this:
Set w = Sys.Process("RobotArm").WaitWindow("#32770", "regexp:(MAIN PAGE)|(Home)", -1, 30000)
If (w.Exists) Then
Call w.Window("Button", "SKIP", 1).Click()
Else
' Not found
End If
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A very good suggestion for me, will continue my work and enjoy with TestComplete. Thank you so much!
