Page 1 of 1

ATag.click losing focus

Posted: Thu Mar 12, 2009 7:56 pm
by Ciege
Sometimes (about 1 in 5 attempts) ATag.click is not actually clicking the link I tell it to. Instead it is causing the web browser to lose focus and (seemingly) randomly clicking somewhere else on the desktop. Please see the following code:

Code: Select all

private static int DOMClickLink(Ranorex.WebDocument webDocumentName, string LinkText)
            Ranorex.ATag DOMlink;

            //Search for the Link on the page
            try
            {
                webDocumentName.EnsureVisible();
                Thread.Sleep(500);
                DOMlink = webDocumentName.FindSingle(".//a[@innertext='" + LinkText + "']");
            }

            catch (RanorexException e)
            {
                Report.Error("Unable to find Link: " + LinkText);
                Report.Screenshot();
                Console.WriteLine("Unable to find Link: " + LinkText);
                return -1;
            }

            //Click a Link
            try
            {
                Report.Info("Clicking Link: " + LinkText);
                DOMlink.Focus();
                Thread.Sleep(500);
                DOMlink.Click(Location.Center);
                Report.Debug("  Clicked Link: " + LinkText);
            }

            catch (RanorexException e)
            {
                Report.Error(e.ToString());
                Report.Screenshot();
                Console.WriteLine(e.ToString());
                return -1;
            }

            return 0;
        } //End DOMClickLink
With the above code I get through the first Try/Catch where I am verifying the link exists on the page. Then it gets to the "Click a Link" section where I get in my report that the link was click. That means as far as Ranorex is concerned the link was clicked (there was no exception thrown). However, a small % of time the link was in fact NOT clicked and my web browser no longer has focus. Obviously this has a detrimental effect on the rest of my code that is expecting that the link was clicked since this function is returning that everything is happy.

Can you take a look at my code and/or the ATag.Click code to see if there is something there you can think of as to why I am losing focus of the web browser and the link is not clicked?

Thanks...

Posted: Thu Mar 12, 2009 11:09 pm
by Ciege
OK, I think this is more than just an ATag issue. I am seeing that after running a script that lasts many minutes (20 - 30) sometimes when Ranorex begins interacting with a WebDocument focus is being lost from the WebDocument. I have many functions like the above function for various elements (ATag, SelectTag, imgTag, InputTag, etc...) most of the iterations of my tests result in these functions working as expected. However, about 10% - 20% of the time Ranorex is losing focus with the WebDocument and not clicking buttons, entering text, etc... as expected. Also, Ranorex is not throwing any exception that this is failing, it just keeps on going happily until my script itself throws an exception that an expected window or expected element is not there.

This testing is being done on a WinXP Pro SP3 machine using IE 7.

My AUT consists on a .NET client/server desktop app as well as a couple of different Web apps that I access through the DOM with Ranorex.

Posted: Fri Mar 13, 2009 11:54 am
by Support Team
Unfortunately, I cannot reproduce the problem.

I tried switching between a windows app and the Ranorex Test Website after each click, filling out the forms, checking the result and doing that in a loop (for about an hour)

Does this only happen when you click on links which load a new site and/or update AJAX content ?

Did you try omitting the .Focus() calls (EnsureVisible should be sufficient) ?
Is there a public website where you can reproduce the problem?

Michael
Ranorex Team

Posted: Fri Mar 13, 2009 7:49 pm
by Ciege
I'm not sure if there is a public website this occurs on, I have not written code to test a public website.

The website/web application I am testing against is fairly vanilla. Not Ajax, just HTML and JavaScript. This is happening very quickly in the web app testing. I launch IE and there is a single link on the page. After I verify that link exists I issue a .Click. Ranorex then seems to be clicking at or around x,y 1,1 of the desktop. (If IE is full screen it opens the menu of IE that you get when you click on the top left icon of the IE application. If IE is not full screen and another app is like Visual Studio it opens the menu of Visual Studio).

I've tried omitting the .Focus calls to no avail. I've tried changing .Click calls to .PerformClick calls. No joy.

This issue is happening with more frequency now (80% of the time). I've also noticed that Ranorex is starting to fail with my windows application where it would normally succeed.

I am going through the process now of uninstalling everything (My stuff and Ranorex) and re-installing back to a hopefully clean state. I'll let you know if this helps or not.

Not sure what is going on here but it is really hurting right now!

Posted: Fri Mar 13, 2009 10:32 pm
by Ciege
So I can't say it's working any better but its not any worse.

Should I be releasing used objects in my code as they become unneeded? Am I running into some kind of resource issue?

Posted: Fri Mar 13, 2009 11:56 pm
by Ciege
OK, I've taken a video of the ATag issue using .Click(). This causes Ranorex to click at 1,1 of the desktop.

I then changed my ATag function to use .PerformClick() instead of .Click and this is successful.

However, as I get passed this section I have another section where I need to .Click() on a InputTag. I have a second video that shows Ranorex moving the cursor to 1,1 of the desktop when .Click() is called.

These videos are 5MB and 3.5MB in size. I have sent them to the Ranorex Support email.

If you want, I can also send you my .cs automation code for you to gander at.

As a last resort, I can send you a VMware image of my entire test environment but this is about 17GB in size.

Posted: Sat Mar 14, 2009 12:17 am
by Ciege
I got a bounce back from your email server that my email was too large in size. I tried resending the email to Christoph's email account since I happened to have that one.

Please let me know if you get the files.

Posted: Mon Mar 30, 2009 12:27 pm
by Support Team
Note to all users experiencing the same problem:
V2.0.2 will fix this problem for non-frames web documents.

Michael
Ranorex Team

Posted: Mon Mar 30, 2009 4:01 pm
by Ciege
Michael & Support Team,

Thank you for your hard work and late nights helping me out with this one! Glad that we were able to find a resolution! Can't wait to try it out in an official release!