How to click a 'next' button of a window using python

£可爱£侵袭症+ 提交于 2019-12-21 21:43:19

问题


I used the below code to connect a opened window(Class type is SunAwtFrame), indeed I able to connect to it. but unable to click next button of it, my doubt is that 'Next' button may reside inside the frame of that window. Even when I use 'swapy' tool, I am unable to navigate through the controls, indeed not showing the controls actually. So, how to switch to frame if it is that case and click the 'Next' button.

app2 = application.Application()

app2.connect(title_re = u'abc')

dialog = app2.abc

print dialog

next =dialog.Next

print next

next.Click()

When I ran the above code I got the error like, Please help me to over come over this

#Error#:-

  <pywinauto.application.WindowSpecification object at 0x025F26F0>
  <pywinauto.application.WindowSpecification object at 0x025FA3B0>
  next.Click()
  File "C:\Python27\lib\site-packages\pywinauto\application.py", line 229, in __getattr__
    ctrls = _resolve_control(self.criteria)
  File "C:\Python27\lib\site-packages\pywinauto\application.py", line 788, in _resolve_contro
l
    raise e.original_exception
pywinauto.findwindows.WindowNotFoundError

回答1:


It seems like you have been trying automate non standard controls by pywinauto. I am recommending you make a click by coordinates, of course if there are no other tasks except press the button.

dialog.Click(coords=(x, y))

or

dialog.ClickInput(coords=(x, y))



来源:https://stackoverflow.com/questions/15607979/how-to-click-a-next-button-of-a-window-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!