sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #08395
Re: [Question #185866]: Handing errors for wait function while looping CSV file
Question #185866 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/185866
Status: Open => Answered
RaiMan proposed the following answer:
Your problem is the standard waiting time of 3 seconds with find
operations (that are internally behind wait and click).
I would solve it this way:
for line in content:
(wrd, nmbr) = eval(''.join(('[', line.strip(), ']')))
print "Website: ", wrd, "Number: ", nmbr
paste(wrd)
type(Key.ENTER)
wait("1327350172734.png", 10)
click(getLastMatch())
wait("llClipfullpa.png", 10)
click(getLastMatch())
wait(4)
type("l",KeyModifier.CTRL)
The combination:
wait("some-img.png", time)
click(getLastMatch())
waits for some-image to come up on the screen for maximum time seconds.
The match is stored internally and clicked afterwards with
click(getLastMatch()).
So if you make the time value sufficient for the special situation, you
will not get a find failed and your code stays lean.
to make it even more lean, you might use
wait("some-img.png", time); click(getLastMatch())
so it is only one line
or even make a def, to reduce it even more (if you need it more often)
def waitClick(img, time = 10):
wait(img, time)
click(getLastMatch())
so instead of
wait("some-img.png", time); click(getLastMatch())
you can now write:
waitClick("llClipfullpa.png")
which would wait for 10 seconds (the defaukt for time in your def)
or
waitClick("llClipfullpa.png", 20)
which would wait for 20 seconds
BTW: def()'s should be in the beginning of your script outside of any
loops or other def()'s
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.