Managing Multiple On-Screen Windows

Hello All,

I am starting to test an application using Eggplant; the application works on the OS level i.e. a lot of navigating between mostly 2 Windows Explorer or 2 Mac Finder Windows.

In an effort not to re-invent the wheel, I was wondering if there are any example scripts of handling multiple windows that might cover some of the following:
* Setup the screen so, a set of variables will tell me the resolution of the SUT and where Window1 is and Window2 in addition to the (x,y) of the top-right and the (x,y) of the bottom left of both windows.
* Making things like verifying a file's presence in WindowA and not in WindowB easier
* Enable predictable drag and drop etc.

Thanks,
Elliot

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    edited September 2010
    I am starting to test an application using Eggplant; the application works on the OS level i.e. a lot of navigating between mostly 2 Windows Explorer or 2 Mac Finder Windows.
    In an effort not to re-invent the wheel, I was wondering if there are any example scripts of handling multiple windows that might cover some of the following:
    There probably aren't going to be a lot of examples of how to work with this kind of setup -- I haven't heard from people with applications that work this way. But I can offer some advice:
    * Setup the screen so, a set of variables will tell me the resolution of the SUT and where Window1 is and Window2 in addition to the (x,y) of the top-right and the (x,y) of the bottom left of both windows.
    If by "resolution" you mean the size of the remote screen, you use the function remoteScreenSize(). I would have the script open a window and drag it to one side of the screen, then open the other window and drag it to the other side. The drags are always deterministic -- whatever you are dragging will always end up in the same place. Having done this, let's now assume that you don't know how big the windows are going to be when they are opened. Capture images of the upper-left and lower-right corners of a window (assuming that these UI elements look the same on every window) and then you could use code like this to get the locations of the corners:
    put everyImageLocation("upperLeftCorner") into ULC
    put everyImageLocation("lowerRightCorner" into LRC
    put (item 1 of ULC, item 1 of LRC) into window1coords
    put (item 2 of ULC, item 2 of LRC) into window2coords
    
    If a window that has focus looks different enough from one that doesn't that the corner images don't match, then you could script it as:
    click "window 1"
    put (imageLocation("upperLeftCorner"), imageLocation("lowerRightCorner") into window1coords
    click "window 2"
    put (imageLocation("upperLeftCorner"), imageLocation("lowerRightCorner") into window2coords
    
    * Making things like verifying a file's presence in WindowA and not in WindowB easier
    If you have a captured image of the file/filename, then this test would look like this:
    if imageFound(imageName:"fileImage", searchRectangle:window1coords) and not imageFound(imageName:"fileImage", searchRectangle:window2coords) then
         logWarning "File found only in Window 1"
    end if
    
    * Enable predictable drag and drop etc.
    I don't actually understand this question. It seems to imply that there is something unreliable or unpredictable about eggPlant's built-in Drag and Drop commands, but all they do is put the mouse down in one location, move to the next location and release the mouse -- it doesn't get much more predictable than that. Are you having and issue with drag and drop?
  • I have started working on this already and I'm glad to see that my work has aligned with your suggestions.

    The one think I didn't realize is that I could add "rectangle:" to the ImageFound button which will really save on unnecessary scripts - thanks for that!
    * Enable predictable drag and drop etc.
    I don't actually understand this question. It seems to imply that there is something unreliable or unpredictable about eggPlant's built-in Drag and Drop commands, but all they do is put the mouse down in one location, move to the next location and release the mouse -- it doesn't get much more predictable than that. Are you having and issue with drag and drop?

    No, I don't mean that Eggplant is not working as expected - it is and I like the product. This was more a summary statement i.e. by having the ability to use two variables WindowA and WindowB it would be easier for me to DnD using them rather than 'guessing' using coordinate-math.
  • BTW: "rectangle:" was not actually searching a specific area of the screen, I had to use "SearchRectangle:"
  • EggplantMattEggplantMatt ForumAdmin admin
    Thanks, Elliot. I fixed my example -- I think I just propagated someone else's error that I had seen recently. BTW, I think the dragging between the windows could be facilitated using the SearchRectangle approach as well:
    drag (ImageName:"someimage", searchRectangle:window1coords)
    drop (ImageName:"someOtherImage", searchRectangle:window2coords)
    
Sign In or Register to comment.