Scroll down drop-down menu and select country

Asked by monicar on 2018-11-08

I am automating Flash application using Sikuli ,IntelliJ and Selenium WebDriver. I am trying to select a country from drop down menu. Using the following code:

 while(screen.exists(country)!=null){
                screen.type(Key.DOWN);
                screen.click(country);

            }

Instead of clicking United states, it's selecting the first value that is Afghanistan.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
monicar
Solved:
2018-11-09
Last query:
2018-11-09
Last reply:
2018-11-08
monicar (monicar) said : #1

I tried the following code:

 do {
                if (region.exists("UNITED STATES") != null) //
                {
                    region.click("UNITED STATES");
                    Flag = 1;
                    break;
                } else {
                    region.type(Key.DOWN);
                }
            } while (Flag != 1);

No luck. Let me know what i am missing

monicar (monicar) said : #2

  Match header = screen.find(country);
            region =header.below(150).left(5).left(1).right(1000);
            do {
                if (region.exists(country) != null) //
                {
                    region.click(country);
                    Flag = 1;
                    break;
                } else {
                    region.type(Key.DOWN);
                }
            } while (Flag != 1);

Above code is working but to select United States it taking more than 10 mins by type Enter on each value and checking if that value exists
Please help

masuo (masuo-ohara) said : #3

set timeout =0 for exists(), it will be faster than it is now.
https://raiman.github.io/SikuliX1/javadocs/org/sikuli/script/Region.html#exists(PSI,double)

But if it takes 600 seconds now, even if it gets faster it will be 200 seconds.

monicar (monicar) said : #4

Awesome, thanks!

On Thu, Nov 8, 2018 at 4:42 PM masuo <email address hidden>
wrote:

> Your question #676023 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/676023
>
> Status: Open => Answered
>
> masuo proposed the following answer:
> set timeout =0 for exists(), it will be faster than it is now.
>
> https://raiman.github.io/SikuliX1/javadocs/org/sikuli/script/Region.html#exists(PSI,double)
>
> But if it takes 600 seconds now, even if it gets faster it will be 200
> seconds.
>
> --
> 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/676023/+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/676023
>
> You received this question notification because you asked the question.
>

monicar (monicar) said : #5

set timeout =0 for exists() resolved my problem. Awesome work Sikuli team.
Thanks for the quick help, Masuo!

screen.click(Country_dd);
                Match header = screen.find(Country_dd);
                region = header.below(150).left(5).left(1).right(1000);
                do {
                    if (region.exists(Country,0) != null) //
                    {
                        region.click(Country);
                        Flag = 1;
                        break;
                    } else {
                       region.type(Key.DOWN);
                    }
                } while (Flag != 1);