我有一个网页,我正在等待按钮出现,当它出现时,我想点击它.该按钮位于计时器上,可能需要一个小时才能显示.此外,如果按钮花费的时间超过一定时间,我想移动鼠标(否则网站会自动将我
所以,等待按钮出现我设计了这个Sikuli脚本:
button = "button.png"
while(1):
if exists(button):
print("found it")
click(button)
break
else:
print("wait longer")
wait(button,30*60)
# do a regular task
print "all done!"
以上似乎没有功能.如果按钮在屏幕上,脚本将找到它…但是,如果它必须等待,它将只是快速超时FindFailed异常(在click()上,即使屏幕上不存在该按钮).我考虑过写一个处理程序,但看起来有点矫枉过正.
我做错了什么,等待这么长时间的视觉事件的最佳方法是什么?
对你有一些其他的想法……while(1):
wait(Button, 30*60) # This will spinlock for 30 minutes for the button to appear
if exists(Button):
hover(Button) # Debug statement allowing user to see what Sikuli has matched to
click (Button)
else:
mouseMove(Location(50,100))
mouseMove(Location(50,200))
链接:
> wait
> mouse movement link
> Location
