.exists doesnt work properly

Asked by saifin on 2018-11-20

so i am trying to locate a element which is located in bottom of screen
i have to scroll down to bottom for that i use type(Keys.down);

but the problem is even though if finds that locator it keeps scrolling and doesnt click on that locator
below is the code for same

  while(s.exists(locator)==null){
   s.type(Keys.DOWN);
   if(s.exists(locator)!=null){
    s.click(locator);
   }
  }

Question information

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

you have to exit the loop after the click:

while(s.exists(locator)==null){
   s.type(Keys.DOWN);
   if(s.exists(locator)!=null){
    s.click(locator);
    break;
   }
  }

RaiMan (raimund-hocke) said : #2

even better:

while(true){
   s.type(Keys.DOWN);
   if(s.exists(locator)!=null){
    s.click(locator);
    break;
   }
  }

saifin (saifin) said : #3

@Raiman
tried both solutions
still it doesnt click on that locator and keeps scrolling down

RaiMan (raimund-hocke) said : #4

are you sure, that the image can be found at all with a score >0.7 (supposing the locator is an image filename).

You might use the SikuliX IDE in parallel to proof your images.

saifin (saifin) said : #5

yup the locator is same i have verified the file name too
how sikulix IDE will be helpful in this

RaiMan (raimund-hocke) said : #6

--- how sikulix IDE will be helpful in this
1. you can script quick-and-dirty trials of images and features
2. you can shot your images and manage them in a script folder

This works for me in the browser with the SikuliX homepage (IDE):

img = <a-shot>
while True:
  type(Key.DOWN)
  if exists(img, 0): break;

where img is an image near the bottom of the page (invisible when starting)

- start the script
- activate the browser page
... and watch

Can you help with this problem?

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

To post a message you must log in.