Forum Discussion

mike_harper's avatar
11 years ago

There was an attempt to perform an action at point (0, 0), which is out of the window bounds

Hi,

I am new to TestComplete and am having a problem with interacting with a Menu link within a web based application.



I have set up the following function:


function ClickCatLink(CatDesc)



{



var browser = Sys.Browser("iexplore");



var page = browser.Page("*");



var obj;



var PropValue;



obj = page.NativeWebObject.Find("contentText", CatDesc);



// Checks the result



if (obj.Exists)



{



Log.Message("Object containing text '" + CatDesc + "' is found", obj.FullName);



obj.Click();



Log.Message("Clicked the " + CatDesc + " object");



aqUtils.Delay(1000);



 



//Move the mouse away from the menu display



Sys.Browser("iexplore").BrowserWindow(0).Click(681, 16);



}



else



{



Log.Warning("Object containing text '" + Cat1Desc + "' was not found.");



}



}



Basically we have a menu listed on the page.

When you select a link from the menu, you are displayed a second page with a new menu, when you select alink from that new menu, you are displayed a third page with yet another menu.



The function works on the very first menu but thereafter it fails when we reach obj.click().

At that point I am displayed the message "There was an attempt to perform ....etc"



Checking the Object Browser, I find that there are in fact 2 objects that meet the criteria when at the secord or subsequent pages. The first object is always the one that is found as a result of the



obj = page.NativeWebObject.Find("contentText", CatDesc);



When viewing this object in the Object Browser and attempting to highlight it on the screen, I am displayed a "Cannot highlight this object on screen" dialog.



The second object found in the Object Browser is never found in the NativeWebObject.Find but in the Object Browser I can successfully highlight the object on the screen.
So I am somewhat puzzled as to how I can successfully Find the correct obj programmically. I really would like to get this to work because then menu system has several thousand combinations with changes to those menu items possibly occurring on a daily basis - hence the need to stay away from hard coded object recognition. Can anyone help me with this please?


1 Reply

  • gid_216's avatar
    gid_216
    Frequent Contributor
    Instead of find use findallchildren. It will return a collection of objects (in your case a collection of both objects). in a for loop, check for another property that is different for these two.

    E.g.



    colObj = page.NativeWebObject.FindAllChildren("contentText", CatDesc, 30, True);

    For Each obj in colObj

     if obj.Visible then  '//Use appropriate property if require

        obj.Click

    end if

    Next