nearby example for windows 7

Asked by Rudiger Wolf

I am getting the following error:

[error] Stopped [error] An error occurs at line 13 [error] Error message: Traceback (most recent call last): File "C:\Users\rwolf\AppData\Local\Temp\sikuli-tmp4509212503442621861.py", line 13, in mTR = mTL.nearby(200).right().find("1301501982214.png") AttributeError: 'int' object has no attribute 'nearby'

The eample I am trying to build is based on the turorial at http://sikuli.org/docx/tutorials/resize/resize.html
I am trying to use hover activated menus in SharePoint list items.

Here is my test script.

setShowActions(True)
myApp=App("Firefox")
myApp.focus()
type(" ", KEY_ALT) # Open windows sizing control
wait(1)
type("x") # Maximize the window

type("l", KEY_CTRL) # switch to address field
paste("http://www.letscollaborate.co.za/Resource-Centre/ResearchDocuments/Forms/AllItems.aspx")
type(""+Key.ENTER)
mTL=hover(XXXXX PICTURE OF ONE OF THE LIST ITEMS XXXXXXX )
#print mTL; hover(mTL)
mTR = mTL.nearby(200).right().find(XXXX PICTURE OF THE BLUE DOWN ARROW that APPEARS on HOVER XXXX )

I want to develop the script further so that I can navigate to and click the "Download a copy" menu item.

I was expecting the nearby method to work in a similar way to the example.

Any suggestions?

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

hover does not return a region object, which is needed for nearby().

you have to say either:

mTL=find(XXXXX PICTURE OF ONE OF THE LIST ITEMS XXXXXXX )
hover(mTL )

or

mTL=hover(XXXXX PICTURE OF ONE OF THE LIST ITEMS XXXXXXX )
mTR = getLastMatch().nearby(200).right().find(XXXX PICTURE OF THE BLUE DOWN ARROW that APPEARS on HOVER XXXX )

Revision history for this message
Rudiger Wolf (rudiger-wolf) said :
#2

Brilliant. Thanks for your advice. I now have it working.
I uploaded a YouTube video of my efforts to help others.

http://www.youtube.com/watch?v=ayIprfBWOAk

def highlightregion(myRegion):
 """ Used to hightlight a region so we know where Sikuli is looking."""
 for i in range(2):
  myRegion.highlight(1)
  wait(0.5)
 return

setShowActions(True) #Enable target circiles for debuging
myApp=App("Firefox") #Look for open App with the Firefox in title
myApp.focus() #Make sure app gets focus

#Maximize browser window
type(" ", KEY_ALT) # Open windows sizing control
wait(1)
type("x") # Maximize the window

type("l", KEY_CTRL) # switch to address field
paste("http://www.letscollaborate.co.za/Resource-Centre/ResearchDocuments/Forms/AllItems.aspx")
type(""+Key.ENTER)
wait(3) # Wait for the website to load

mTL=hover( ) # My Target Line
mTR = getLastMatch().nearby(20).right() # Expand the Target area by 20 pixels and look to the roight of the screen
highlightregion(mTR) #Make the region visible for debuging
mTR=mTR.find( )
lookInRegion=mTR.nearby(200) #Create a region to limit activity to
highlightregion(lookInRegion) #Make the region visible for debuging
lookInRegion.click(mTR,3) #Click on the dropdown button
lookInRegion.wait( ) # Wait for the drop down menu
lookInRegion.hover( ) # Hover over the menu, we expect a cascading menu to appear
lookInRegion.click( ,3) # Click on the download menu