EnsureVisible() method doesn't ensure whole object visible

Class library usage, coding and language questions.
User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

EnsureVisible() method doesn't ensure whole object visible

Post by daa » Fri Jun 11, 2010 2:34 pm

Version: Ranorex 2.3.0.8345

I'm automating web application testing, and I have a generic "click on some tag by RxPath" method, that looks like this:

Code: Select all

        public static void ClickTag(string aRxPath)
        {
            Ranorex.WebElement lTag = aRxPath;
            lTag.EnsureVisible();
            Mouse.Click(lTag);
        }
The problem is that whatever's underneath EnsureVisible() seems to regard a web element as visible if any pixel is showing on the screen. This means that the click sometimes doesn't happen, if previous bits of code have left the screen such that the next thing to click has just a few pixels visible. Note that the Mouse.Click() method defaults to Location.Center, but changing the location wouldn't help anyway, since you could, by other screen moves, have any edge of the object [not] visible.

Is there an EnsureEntireObjectVisible() method, or a workaround for this please?
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: EnsureVisible() method doesn't ensure whole object visible

Post by Support Team » Mon Jun 14, 2010 5:48 pm

Youre right, thats definitely wrong behavior. It should make the element totally visible (if possible).
I was able to reproduce this in Internet Explorer, but not in Firefox.
A possible workaround would be to check if the element rectangle intersects the web document rectangle and then scrolling to some element on the top/bottom to make your target element completely invisible. Thats a bit ugly, though.
Or you try using the WebElement.PerformClick method to invoke a click on the element instead of a real click with the mouse.

We will provide a fix for this in the next maintenance release (V2.3.2)

Michael
Ranorex Team
.
Image