How to click a 'next' button of a window u

2019-04-12 15:06发布

问题:

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))