Waiting until Image no longer exists to continue test : General Questions

Waiting until Image no longer exists to continue test

Ask general questions here.

Waiting until Image no longer exists to continue test

Postby smalldoorman » Thu Sep 30, 2010 12:08 am

I'm trying to test a Flash game where there is loading sessions between areas but the load times vary dependent on machine several other factors. There is a loading screen between areas, I'm wondering if there is some sort of command that i can put it that tells Ranorex to wait until the preloader images no longer exist then proceed with its test?
smalldoorman
 
Posts: 14
Joined: Thu Aug 12, 2010 11:37 pm

Re: Waiting until Image no longer exists to continue test

Postby Ciege » Thu Sep 30, 2010 12:59 am

Do you have a link to the image object? If so you can do something like this...

Code: Select all
bool ImageVisible = ImageObject.Visible;
while (ImageVisible == true)
{
  Thread.Sleep(500);
  ImageVisible = ImageObject.Visible;
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Waiting until Image no longer exists to continue test

Postby smalldoorman » Fri Oct 01, 2010 8:41 pm

I do have a url link for each loading image. Where would this go (I'm learning C# as time goes so please bear with me), would it replace the ImageObject.Visible?
smalldoorman
 
Posts: 14
Joined: Thu Aug 12, 2010 11:37 pm

Re: Waiting until Image no longer exists to continue test

Postby Ciege » Fri Oct 01, 2010 10:13 pm

I'm sorry, I meant an xPath link to the object. In other words have you created a variable that references your object? That is what ImageObject represents in my example code.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Waiting until Image no longer exists to continue test

Postby smalldoorman » Fri Oct 01, 2010 11:57 pm

Oh ok. Now am i creating method solely for this or am i adding it as part of another method? Please do not that I will be creating at least 25 unique checks.
smalldoorman
 
Posts: 14
Joined: Thu Aug 12, 2010 11:37 pm

Re: Waiting until Image no longer exists to continue test

Postby Ciege » Sat Oct 02, 2010 12:01 am

What I would do is create a new method cal WaitUntilExists or something similar that takes an object as a variable. You call that method with the object passed in and it will wait until that object exists.
So, create the method once and use it however many times you want.

Just to be clear, when done you will have created a framework method that can be used with any project you want.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: Waiting until Image no longer exists to continue test

Postby smalldoorman » Mon Oct 04, 2010 7:50 pm

I cannot pull an Xpath with Spy since the everything on the screen is being shown as one flat image, Spy isn't picking up every individual piece of art.

Is there any way that i can put the image into the repository and reference the image from there? So far when i substitute the image file name from the repository for ImageObject, I had Ranorex simplify the file path and then put that in place of the ImageObject Variable (assuming that was the correct step). But the method keeps coming back as invalid. Below is the method I'm trying to use.

Code: Select all
public static void ValidateHud()
    {
        bool ImageVisible = .//img[@alt=.Visible;
        while (ImageVisible == True)
        {
            Thread.Sleep(500);
            ImageVisible = .//img[@alt=.Visible:
        }
    }
smalldoorman
 
Posts: 14
Joined: Thu Aug 12, 2010 11:37 pm

Re: Waiting until Image no longer exists to continue test

Postby smalldoorman » Mon Oct 04, 2010 7:54 pm

It is also an option for me to put a check in that instead of waiting for the loading screen to turn off is to put a wait until exists, So that Ranorex is waiting until the HUD shows up, which is one of the last things to load for our flash applet.
smalldoorman
 
Posts: 14
Joined: Thu Aug 12, 2010 11:37 pm

Re: Waiting until Image no longer exists to continue test

Postby sdaly » Tue Oct 05, 2010 1:03 pm

Something like this may be what you are after?


Public Sub waitUntilImageNotExists(strRanorexPath as String, strBmpFilePath as String, intTimeout as Integer)

Dim containingItem as Ranorex.Unknown = strRanorexPath
Dim bmp As System.Drawing.Bitmap = Ranorex.Imaging.Load(strBmpFilePath)
Dim iterations as Integer = 0

While imaging.Contains(containingItem.Element, bmp)
delay.Seconds(1)
iterations += 1
If iterations > intTimeout - 1 Then
report.Failure("Image", strBmpFilePath & " has not dissapered within " & intTimeout.ToString)
Throw New Exception
End If
End While
Report.Info("Image", strBmpFilePath & " no longer exists within " & strRanorexPath)

End Sub
User avatar
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: Waiting until Image no longer exists to continue test

Postby smalldoorman » Mon Oct 11, 2010 8:55 pm

Thanks for all the help guys, I think I'll forgo this step until I finish all my test cases and add this back in as a nice to have, for now I'll just put a large delay time.
smalldoorman
 
Posts: 14
Joined: Thu Aug 12, 2010 11:37 pm


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests