Having trouble detecting maximize button

I have a link that I need to click on a webpage but it is not visible unless the window is maximized.

I am trying to use the following code:


if imageFound(15,"image0003")
     Click "image0004"
end if
Click "Test_2/select_all"

image0003 = minimize/maximize button on an XP machine in the minimized state. That is, it is not full screen. Shows a single window rather than the cascaded ones.

image0004 = same button. In theory, I could use the same image for both, since they are.

select_all is a link I need to select.

I realize I could tab to the link or scroll down. I’d prefer to solve this problem as it is though.

Thanks.

[quote=“sygyzy”]I have a link that I need to click on a webpage but it is not visible unless the window is maximized.

I am trying to use the following code:


if imageFound(15,"image0003")
     Click "image0004"
end if
Click "Test_2/select_all"

[/quote]
You didn’t actually say what the problem is. Your code looks fine and based on your description of the images, it seems like it should be working. That said, I would suggest a modest rewrite of your code:


if imageFound(15,"image0003")
     Click foundImageLocation()
end if
Click "Test_2/select_all"

FoundImageLocation returns the coordinates at which the last image found by Eggplant is located – this saves having to do another search for an image that has already been located. I would also suggest that your code will be easier to read if you give all of your images meaningful names – I see that you did that for your “select_all” image, so the code above probably just represents a quick trial.

Let us know what problem you’re having and we can try to get you past it.

  • Matt

Hi,

Thanks for the suggestion with the new tag. I knew there must have been a better way. This way, I don’t have to save two images.

The problem is that it never finds the button. I have tried increasing the timeout too. Maybe I’ll increase it even more.

P.S. Does it search from the upper left to right, down? Or some other direction?

Eggplant searches the screen from the upper left to the lower right, sweeping across the screen and then moving down for the next sweep.

If you just highlight the line of your script that is supposed to click on the maximize button and run it using the Run Selection toolbar item, does it find the image then (assuming it’s on the screen)? If you continue to have trouble with this, send us (support@redstonesoftware.com) the image and the ScreenError.tiff file that is generated when the script fails and we can analyze the image to see if there are any differences that are causing the failure.

Hi

I quickly figured out the problem after posting here. I typed in the wrong image filename and so it was searching for something that did not exist. Easy fix.

Sometimes I run across detection problems that are not as simple to figure out. It’s pretty frustrating. Luckily, in this case, it was pretty obvious after I checked what the filenames corresponded to.

Glad to hear you figured this one out. For other image detection issues, if you have not already done so, you might read the article on page 18 of the “Using Eggplant” guide entitled “Failure to Find an Image That Is on the Screen”. This has a discussion of why images are sometimes not found, and ways to modify Eggplant and/or your scripts to fix this problem. You might also want to look at another of my forum posts that details how to compare images in Photoshop to see what differences they might have at the pixel level (http://www.redstonesoftware.com/phpbb2/viewtopic.php?t=180&start=0&postdays=0&postorder=asc).

  • Matt