Every time only 2 objects are returned from findAll function

Asked by Saorabh Singh

Choose.png &Choose1.png are the Images to be searched in Screen.
which has 4 similar Objects..& find all Shud return 4 different regions.
But instead it returns only 2 matched region.

please have a look at it & help me.

If you need those images..please let me know,where & how can i send it??

JAVA CODE::

String qlist = new String();

Pattern QTextbox = new Pattern(imagePath + "android/imgs/Choose.png");

QTextbox.similar((float) 0.3);

Iterator<Match> match=s.findAll(QTextbox);

Pattern QTextbox1 = new Pattern(imagePath + "android/imgs/Choose1.png");

QTextbox1.similar((float) 0.3);

Iterator<Match> match1=s.findAll(QTextbox1);

Region Rfind = null;

System.out.println("\n New Serach");

for(int i=0;i<numOfQuestionsToBeCreated;i++)

{

     qlist=match.next().text();
     System.out.println("\nStrings : " + qlist);
     Rfind =match.next().inside();
     System.out.println("Region Returned :"+i+"= " + Rfind);
     Rfind.click(QTextbox,0);

if(!match.hasNext())
    break;

}

for(int i=0;i<numOfQuestionsToBeCreated;i++)

{

   qlist=match1.next().text();
   System.out.println("Strings : " + qlist);
   Rfind =match1.next().inside();
   System.out.println("\nRegion Returned :"+i+"= " + Rfind);
   Rfind.click(QTextbox1,0);

   if(!match1.hasNext())
   break;
}

Console OUTPUT For Above code::

New Serach

Strings : Choosea question ~
Region Returned :0= Match[677,373 124x14] score=0.97, target=center
Using substitute bounding box at (222,2)->(239,5)
PyramidTemplateMatcher: source is smaller than the target
[log] CLICK on (739,380)

Strings : Choosea question
Region Returned :1= Match[677,332 124x14] score=0.92, target=center
[log] CLICK on (739,339)
PyramidTemplateMatcher: source is smaller than the target

Strings : (`hnnsea nuestinn
Region Returned :0= Match[677,414 109x13] score=0.98, target=center
PyramidTemplateMatcher: source is smaller than the target
[log] CLICK on (731,420)

Strings : fhnncnA nuncrinn
Region Returned :1= Match[677,331 109x13] score=0.92, target=center
PyramidTemplateMatcher: source is smaller than the target
[log] CLICK on (731,337)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

I guess the problem is that:

QTextbox.similar((float) 0.3);

does not change the similar attribute of QTextbox as you might expect, but it returns a new pattern object.

So try:

QTextbox = QTextbox.similar((float) 0.3);

Revision history for this message
Saorabh Singh (kunnu30) said :
#2

Thanks RaiMan, that solved my question.