Loop Fails

Asked by Andrés Portocarrero Bonifaz on 2017-11-06

Good Afternoon, my loop is running correctly for about 4-5 loops. After that, I get the following error.

FindFailed (...png (87x23) seen at (569,407) with 1,00 in S(0)[0,0,1366x768]E:Y,T:3,0)
[Error] --- Trackback --- error source first line: module (function) statement 45: main (loopAngulo)
doubleclick(X.png)
trackback---end

It seems that in the loop number 5 it is not taking into account lines 40 and 41 and I don't know why. What worries me is that the first loops are working fine. Here is my code:

def loopAngulo(i):
    j=85.5
    while j <= 90:
        doubleClick("1509640412186.png")
        wait(1)
        type("K")
        type(Key.ENTER)
        wait(1)
        type("L")
        type(Key.ENTER)
        wait(1)
        type (str(i))
        type(Key.ENTER)
        wait(1)
        type (str(2))
        type(Key.ENTER)
        wait(2)
        type (str(3.27))
        type(Key.ENTER)
        wait(1)
        type (str(j))
        type(Key.ENTER)
        wait(1)
        type (str(1))
        type(Key.ENTER)
        wait(2)
        type ("D")
        type(Key.ENTER)
        type(Key.ENTER)
        wait(2)
        type (str(50))
        type(Key.ENTER)
        wait(2.2)
        type (str(2))
        type(Key.ENTER)
        wait(2.2)
        type(Key.ENTER)
        wait(2.5)
        type(Key.ENTER)
        wait(2.4)
        type(Key.LEFT)
        wait(3)
        type(Key.ENTER)
        wait(3)
        doubleClick("1509667530944.png")
        wait(3)
        type (str(i))
        wait(1.2)
        type(Key.ENTER)
        wait(1.2)
        type (str(j))
        wait(1.5)
        type(Key.ENTER)
        wait(1.6)
        type(Key.ENTER)
        j+=1.5

i=1.36
while i <= 1.48:
    loopAngulo(i)
    i+=0.12

Question information

Language:
English Edit question
Status:
Open
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-11-06
Last reply:
2017-11-06
RaiMan (raimund-hocke) said : #1

The image is no longer there in that moment.

Indeed, but it isn't there for a reason, the previous instructions aren't working correctly and I can't figure out why. As I mentioned the first loops are working correctly but it reaches a point it stops are working correctly. It isn't the loop conditions because it changes just the inputs parameters.
I was thinking it could be a problem with the wait instructions. Maybe somehow they are becoming longer after each loop, could that be possible?

RaiMan (raimund-hocke) said : #3

using such constructs like:
      wait(2.4)
      type(Key.LEFT)

can be risky, since it depends on that the targeted GUI gets ready for accepting the Key.LEFT latest after 2.4 seconds. If this varies for whatever reason, then you have a problem: if it takes 3 seconds, then the Key.LEFT is a noop.

So you either have to adjust the wait times somehow, or you have to add visual checks to decide, wether the GUI is ready for the next action or instead of wait(time) use someRegion.wait(someImage) to wait for the GUI to be ready.

Thanks a lot.

El 6 nov. 2017 12:53 PM, "RaiMan" <email address hidden>
escribió:

> Your question #660409 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/660409
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> using such constructs like:
> wait(2.4)
> type(Key.LEFT)
>
> can be risky, since it depends on that the targeted GUI gets ready for
> accepting the Key.LEFT latest after 2.4 seconds. If this varies for
> whatever reason, then you have a problem: if it takes 3 seconds, then
> the Key.LEFT is a noop.
>
> So you either have to adjust the wait times somehow, or you have to add
> visual checks to decide, wether the GUI is ready for the next action or
> instead of wait(time) use someRegion.wait(someImage) to wait for the GUI
> to be ready.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/660409/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/660409
>
> You received this question notification because you asked the question.
>

Can you help with this problem?

Provide an answer of your own, or ask Andrés Portocarrero Bonifaz for more information if necessary.

To post a message you must log in.