← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #162372]: Best way to code closing a browser(app) triggered after a complete windows copy event

 

Question #162372 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/162372

RaiMan proposed the following answer:
Calle's suggestion is the principal approach, to solve such a situation.

I prefer this variant:
while exists(image, 0): wait(1)

advantage: this loop will end latest about 2 second after the progress
window vanished. Calle's will take 3  to 8 seconds (waiting time 3
seconds plus 5 seconds).

if you only want to wait, you might try:
waitVanish(image, FOREVER)

The above loop is equivalent, but only needed, if you want to do
additional things while waiting.

But I think there is an additional challenge:
After clicking the save button, it might take some time for the progress window to come up.
So supposing, that it gets visible in all cases, I would do it this way:

while not exists(image, 0): wait(1) # waits for it
while exists(image, 0): wait(1) # waits for it to vanish

---- some general comments on your script:

-- whenever possible, one should use keyboard shortcuts instead of clicking menu entries
click(File.png)
click(SavePageAs.png)

could be substituted by:
type("s", KEY_CTRL+KEY_SHIFT)

-- usage of exists()
exists(FilenameBox.png,0)

simply does "nothing": it makes one try to find the image and comes back if found or not.
what makes sense here would be:

while not exists(FilenameBox.png,0): wait(1)

this would wait for the file dialog to be ready for the following paste.

-- same for this sequence:
wait(5.0)
exists(SaveButton.png), 0)
click(getLastMatch())

better:
while not exists(SaveButton.png, 0): wait(1)
click(getLastMatch())

--- make scripts robust:
have a look at faq 1607

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.