How to deal with drop down menus in situations, where they vanish too early

Asked by can

The behavior of these functions (such as wait, exists, find) appears to be changed after the upgrade of the Sikuli (1.0.rc3 -> 1.1.0)

the code:
click(DropDownBoxPic)
r = exists(pic1) / r = find(pic1) / r = wait(pic1)

In v1.0rc3:
After the execution of the code, the drop-down box is still unfolding

In v1.1.0:
After the execution of the code, the drop-down box has been retracted

my question:
Is this new feature in v1.1.0?
What method can have such effect, let drop down list has been in the expansion state in v1.1.0 ?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
can
Solved:
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

I cannot reproduce this behavior with final 1.1.0.

So you must be more specific e.g. with a real code sample.
What is the system and what is the app, that has the dropdown?

Revision history for this message
can (ting) said :
#3

yes, when operating the drop-down box, they are different.

to simplify the description, the assumption has been opened a web. e.g. http://www.msn.com/en-us
and move the scroll bar until the drop-down box appears on the screen.
I chose the location of the drop down box " Research | Listings | Quotes "

I want get the screenshot of the drop box "New" in "Research".
so my code:
click("Research.png")
click("New.png")
r = exists("New.png")
capture(r)

but I found that the drop down payment to go back after the execution of this statement "r = exists("New.png")"

I'm confused
why the behavior in the new version is this?

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Sorry, but I cannot reproduce the problem. works fine with final 1.1.0.

tested on
- Mac: Safari and Chrome
- Windows: Chrome

the masn page was already scrolled down to the Autos section

Testscript (on Windows):
img = Pattern("img.png").targetOffset(-4,28) # image of Research | Listings | Quotes including button new below
m = find(img) # find it
reg = m.below(200).grow(10)
#reg.highlight(2) # optionally highlight the search region
click(m) # click the New button
new = "new.png" # the new entry in the drop down
if reg.exists(new):
  print "found"
  reg.highlight(-2)
else:
  print "not found"

prints "found" and highlights the new entry image at the place it was found (though highlight makes the dropdown vanish)

Revision history for this message
can (ting) said :
#5

sorry, I describe the phenomenon, but forget to say the operating environment.

tested on
-Windows 7 (64bit): IE9

I also tried the code you gave.
The highlight of the coordinates is not wrong, but the drop-down box has vanished.
I want to express the meaning is this "vanished".It may be limited to my English level.

after the confirmation of the drop-down box appears,i use the function (capture()) to capture the drop-down box.
but now, i find the drop-down box has vanished.
when using the sikuli 1.0rc3, there is no such a situation

Revision history for this message
RaiMan (raimund-hocke) said :
#6

why the dropbox has vanished in the above example, I explained:
highlights the new entry image at the place it was found (though highlight makes the dropdown vanish)

if you modify the example this way:

img = Pattern("img.png").targetOffset(-4,28) # image of Research | Listings | Quotes including button new below
m = find(img) # find it
reg = m.below(200).grow(10)
#reg.highlight(2) # optionally highlight the search region
capture(reg) # capture the search region
click(m) # click the New button
new = "new.png" # the new entry in the drop down
if reg.exists(new):
  print "found"
  #reg.highlight(-2)
  capture(reg.getLastMatch())
else:
  print "not found"

... it should do what you want

If you test such snippets in the IDE, you should add a
wait(5)
at the end of the script, to have a chance, to see what really happens.

Revision history for this message
can (ting) said :
#7

Thank you for your detailed explanation.

the logic of the code design is
first, confirm the new.png (By this code to achieve: "if reg.exists(new):" )
if there is, then capture the new entry in the drop down (By this code to achieve: "capture(reg.getLastMatch())" )

when capture the new entry in the drop down, need a Region
so I use the find function to get the Region (By this code to achieve: "reg.getLastMatch()" )

before the execution of this statement "capture(reg.getLastMatch())", add a statement "click(m)"
let the disappearance of the drop-down box appears again

..now i know the reason for the dropdown vanish
May I ask if there are other ways to achieve this operation process?

Revision history for this message
RaiMan (raimund-hocke) said :
#8

--- May I ask if there are other ways to achieve this operation process?
might be, I do not know.
The mentioned way was the one I figured out, to test, wether we have a problem and that is enough for me ;-)

Revision history for this message
can (ting) said :
#9

ok, i got it