Sikuli api - "OK" click ignored during file upload

278 Views Asked by At

Using:

  • Sikuli-api stand alone jar
  • python 2.7.6 with pyjnius
  • Ubuntu 14.04 Trusty

Issue:

The Sikuli DesktopMouse click() method works in almost all situations except when I'm trying to click "Open" on a file upload [Ubuntu Open](https://i.stack.imgur.com/nZsvv.png) from the upload dialog or "Allow" on the Flash Player Settings dialog [Flash Player Settings](https://i.stack.imgur.com/7OrbG.png). If I navigate to these areas manually I can click on these buttons without error. I have to imagine that it is some sort of permissions issue (because all other clicks work including all the clicks in the code snippet below. I mean, the exception at the bottom is thrown, meaning that the "Open" button is both seen and clicked on, twice), but I haven't the foggiest what that would entail. There are no errors to share because the click doesn't technically fail

About Code:

self.get_target() returns an ImageTarget
self.mouse and self.kb are instances of DesktopMouse and DesktopKeyboard respectively.
self.box creates a DesktopCanvas and draws a box around the target DesktopScreenRegion

Code:

def upload_file(self, path, title):
    screen = sikuli.DesktopScreenRegion()
    locationTarget = self.get_target("images/ubuntu_location_field.png")
    locationTarget.setMinScore(.6)
    locationField = screen.wait(locationTarget, 5000)

    if locationField is None:
        editTarget = self.get_target("images/ubuntu_location_edit.png")
        edit = screen.wait(editTarget, 5000)
        if edit is None:
            searchTarget = self.get_target("images/ubuntu_upload_search.png")
            search = screen.wait(searchTarget, 5000)
            self.box(search)
            self.mouse.click(search.getCenter())
        else:
            self.box(edit)
            self.mouse.click(edit.getCenter())
        locationField = screen.wait(locationTarget, 5000)

    self.mouse.click(locationField.getCenter())
    self.kb.type(path + "/" + title)

    okTarget = self.get_target("images/ubuntu_upload_opensave.png")
    ok = screen.find(okTarget)
    self.mouse.click(ok.getCenter())

    if screen.find(okTarget):
        self.mouse.click(ok.getCenter())
    if screen.find(okTarget):
        #GETTING TO THIS POINT MEANS THAT THE BUTTON CAN BE SEEN AND CLICKED
        #BUT THAT THE CLICK IS NOT DOING ANYTHING
        raise Exception("Upload file is acting like a bitch.")

    sikuli.API.pause(10000)


1

There are 1 best solutions below

0
On

Found that the issue stemmed from using the firefox webdriver, which apparently has much higher security than its chrome counterpart. All operations can be done on chromedriver.