Hello,
I am working from a list on a dynamically generated web page. The only real identifier on the page is the empty checkbox next to each record in the list of results. I need to open each record (done by clicking each box) individually.
Problem is, for each list of results there are anywhere from 20 of these identical checkboxes on the screen.
So, for instance:
1. Box John Smith
2. Box Chuck Jones
3. Box Bob Williams
...
20. Box Steve Adams
Is there a way to setup an image recognition to recognize an image in a series of identical images?
So, find image 1 of 20, click...find image 2 of 20, click...find image 3 of 20, click, etc.
Thanks,
rj
Selecting an image when there are multiple copies of it
Moderators: JRL, Dorian (MJT support)
Re: Selecting an image when there are multiple copies of it
With FindImagePos> you will get an array of all the matches found and their coordinates, which can then be looped through and clicked. To get a more robust solution you can probably use the Web commands available in MS. Is it a public website you can share?
Re: Selecting an image when there are multiple copies of it
As hagchr says you can get a list of all coordinates using FindImagePos>. But to get the array of all coordinates you must use the "EXACT" match algorithm. See help for FindImagePos>.
Re: Selecting an image when there are multiple copies of it
Thanks for the replies!
@hagchr - unfortunately, it isn't a public site, but here's a somewhat similar example (in principle nonetheless):
http://www.ebay.com/sch/Cars-Trucks-/6 ... Type=Coupe
the image "Year:" would be similar to the buttons, in this instance, clicking on "Year:" wouldn't do anything, but it still perfectly illustrates the situation I was asking about. Stacked one under the other, etc.
@JRL - thanks for the EXACT info! I'm looking up the help menu now.
@hagchr - unfortunately, it isn't a public site, but here's a somewhat similar example (in principle nonetheless):
http://www.ebay.com/sch/Cars-Trucks-/6 ... Type=Coupe
the image "Year:" would be similar to the buttons, in this instance, clicking on "Year:" wouldn't do anything, but it still perfectly illustrates the situation I was asking about. Stacked one under the other, etc.
@JRL - thanks for the EXACT info! I'm looking up the help menu now.
Re: Selecting an image when there are multiple copies of it
Hi, one way to get the links and click on them, using the source code of the page and extracting the links, without using image recognition. One can probably use some of the other MS web commands to get it in an easier way, but hopefully it illustrates one way. It would obviously depend on the web page being stable and not changed frequently. Happy to walk you through it if you have any questions.
Code: Select all
//Create IE instance and maximize
IECreate>IE[0]
IEGetHWND>IE[0],IEMain
IEShowIE>IE[0],1
Let>WIN_USEHANDLE=1
WindowAction>1,IEMain
Let>WIN_USEHANDLE=0
//Navigate to site
Let>URL=http://www.ebay.com/sch/Cars-Trucks-/6001/i.html?Body%2520Type=Coupe
IENavigate>IE[0],URL,res
IEWaitDocumentComplete>IE[0],res
//Get the source code
IEExtractTag>IE[0],,BODY,0,1,res
//Extract out all the links
Let>tmp0=(?ms)<li class="sresult.+?<a class.+?href="\K[^"]+
RegEx>tmp0,res,0,m,nm,0
//Loop through and click on the - here - first 5 links
Let>ctr=0
While>ctr<5
Add>ctr,1
Let>tmp=m_%ctr%
IENavigate>IE[0],tmp,res
IEWaitDocumentComplete>IE[0],res0
EndWhile
//In case you want to see the links, otherwise delete
Let>reslinks=
Let>ctr=0
While>ctr<nm
Add>ctr,1
Let>tmp=m_%ctr%
Let>reslinks=%reslinks%%tmp%%CRLF%
EndWhile
MDL>The links are:%CRLF%%reslinks%
Re: Selecting an image when there are multiple copies of it
Hi hagchr,
I appreciate the help!
I should have mentioned earlier that unfortunately the sites I have to work with don't work well within IE. For some reason, IE chokes on the ajax elements.
As a result, I have to use either Firefox, Chrome or Maxthon for most of my scripts, thereby rendering Webrecorder and the web commands within MS14 unusable...
I appreciate the help!
I should have mentioned earlier that unfortunately the sites I have to work with don't work well within IE. For some reason, IE chokes on the ajax elements.
As a result, I have to use either Firefox, Chrome or Maxthon for most of my scripts, thereby rendering Webrecorder and the web commands within MS14 unusable...
Re: Selecting an image when there are multiple copies of it
Hi, not sure what you will do on each web page, but in case you just want to extract data you may also be able to use HTTPRequest>. This will give you the list of links. You could use the same structure to loop and get the HTML from each page and then extract whatever info you are looking for.
Code: Select all
//Get the relevant links that needs to be clicked
CODEBLOCK
//Get source code
Let>URL=http://www.ebay.com/sch/Cars-Trucks-/6001/i.html?Body%2520Type=Coupe
HTTPRequest>URL,,Get,,strHTML,,,,
//Extract all relevant links
Let>tmp0=(?ms)r="\d\d?".+?<a href="\K[^"]+
RegEx>tmp0,strHTML,0,m,nm,0
ENDCODEBLOCK
Let>resLinks=
Let>ctr=0
While>ctr<nm
Add>ctr,1
Let>tmp=m_%ctr%
Let>resLinks=%resLinks%%tmp%%CRLF%
EndWhile
MDL>Links to click:%CRLF%%resLinks%