Automating expand-collapse buttons using Sikuli

Asked by Aravind

I have a directory structure like this
1.folder1
2.folder2
3.folder3
4.folder4
   file1
   file2
   file3
These folder1,2,3,4 inturn have a few folders or files in it. And assume that these no:s 1,2,3,4 to be expand buttons depicted by a 'folder'symbol all looking alike. And what I'm trying to acheive is that when I click on these folder symbols I should get an expanded view till all the child most files are visible. Any solutions to make this possible ?

And moreover I want to search for a particular file out of these expanded view, the filename of which I know well in advance.
How OCR will help me achieve this ?

Question information

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

no ned to do that visually.

just use the many features available as standard Python:
http://docs.python.org/2.6/library/filesys.html#file-and-directory-access

Revision history for this message
Aravind (a4aravind) said :
#2

I'm forced to reopen this ....Is it possible via a mouse click....In my application, the file resides in a remote server and I want it to be downloaded to my local machine. So only I'm expanding these folders to view that particular file and do a download via a click on the download image.

This is what I have coded:

for i in docsReg.findAll("folders.png"):
        count+=1
        docsReg.exists("folders.png").highlight(2)
        doubleClick(i)
        wait(1)

But this one identifies all the initial locations of the folders.png symbols but sikuli don't understand that these initial locations will change to the bottom after an expansion has occured. But again it's clicking on the initial location only where it was at first :( What I want is, it should understand the new location(somewhere to the bottom of the initial location) after the expansion has taken place once.
Any help please....

Revision history for this message
RaiMan (raimund-hocke) said :
#3

This is not possible with Sikuli this way, since Sikuli does not track a GUI about changing the position of an image after an action.
Furthermore, findAll() does not return the matches in some order (top down in your case).
And a last possible challenge: the expansion might make the lower part of the list invisible, because it extends beyond the bottom of the browser window, so it gets invisible (which means not accessible for Sikuli without scrolling).

Since doing this visually is a very complex process, I recommend, to first look for another solution based on standard Python modules (e.g. urllib) or utilities like wget.

Revision history for this message
Aravind (a4aravind) said :
#4

Found out a solution for this, though it won't solve the 'last possible challenge' in the above comment.
This was my previous code :
for i in docsReg.findAll("folders.png"):
        count+=1
        docsReg.exists("folders.png").highlight(2)
        doubleClick(i)
        wait(1)

The problem with this code is that this one identifies all the initial locations of the folders.png symbols but won't identify the new locations after an expansion occurs. For that what I did is that do one expansion, go somewhere outside the region and click, come again inside the region(this time again it checks for all the locations of the folders.png, which include the newly changed locns) and manipulate. And you have to do this after every click on an expansion button.

So here goes my new code snippet:
for i in docsReg.findAll("folders.png"):
        click("outside.png") # somewhere outside the docsReg
        count+=1
        docsReg.exists("folders.png").highlight(2)
        doubleClick(folders.png)
        wait(1)

Seems to work well for me !!