Select last item in a drop down box

Asked by Richard Mullins

I am looking for some help, re drop down box's,

Basically I need to select the last option in a drop down box, which is simple enough however the problem I have is that the contents of the dropdown box change everyday so an image wont help. however for the test I am creating I need Sikuli to select the last in the list.

Do you know of a way selecting the last option in a list?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hi,

I see 2 possible cases here:
1. The number of menu items is constant
2. The number of menu items is changing

So for the first case you have the following options:
1. "Click your way to the last element"

Click on the drop down menu to expand it and, assuming that the first menu item will be highlighted, just use "type(Key.DOWN)" for a number of times that will take you to the last item. Then hit Enter to accept the item.

2. Offset
You can select an object on the screen and use it as a pivot to offset your mouse clicks to select the last item in the menu.

For the second case(when the number of menu items is changing) it's a bit more tricky.
The only way I can think about is just clicking "Down" button enough times to reach the last item for sure. Or, if when you reach the last item and continue going down the selection moves back up, you can try to click "Up" once when the first item in the menu is highlighted and it will skip to the last item. But that really depends on your menu behavior.

Cheers,
Eugene

Can you help with this problem?

Provide an answer of your own, or ask Richard Mullins for more information if necessary.

To post a message you must log in.