使用:
问题:
Sikuli DesktopMouse click()方法适用于几乎所有情况,除非我在文件上传时单击“打开”[Ubuntu Open](http://i.stack.imgur.com/nZsvv.png )来自上传对话框或Flash Player设置对话框中的“允许”[Flash Player设置](http://i.stack.imgur.com/7OrbG.png)。如果我手动导航到这些区域,我可以单击这些按钮而不会出错。我必须想象它是某种权限问题(因为所有其他点击工作包括下面代码片段中的所有点击。我的意思是,底部的异常被抛出,这意味着“打开”按钮都被看到了点击,两次),但我没有那个最模糊的东西。没有错误要分享,因为点击技术上不会失败
关于代码:
self.get_target()
返回ImageTarget
self.mouse
和self.kb
分别是DesktopMouse和DesktopKeyboard的实例
self.box
创建一个DesktopCanvas并在目标DesktopScreenRegion
代码:
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)
答案 0 :(得分:0)
发现问题源于使用firefox webdriver,它显然比chrome对手具有更高的安全性。所有操作都可以在chromedriver上完成。