How to perform a Click action in a Button or Text field using pywinauto

I am using pywinauto for automation. Click on a button on the DiffDaff software.

My intention:

  • Step 1: Open DiffDaff Software

  • Step 2: click "About"

    from pywinauto.application import Application
    
    app = Application.start("C:\Program Files\DiffDaff\DiffDaff.exe")
    
    app.About.Click()
    

But I am in step 2, and the console shows an error:

  File "build\bdist.win32\egg\pywinauto\application.py", line 238, in __getattr__
  File "build\bdist.win32\egg\pywinauto\application.py", line 788, in _resolve_control
pywinauto.findbestmatch.MatchError: Could not find 'About' in '['', u'DiffDaff - Compare Files, Folders And Web Pages', u'Internet Explorer_Hidden', u'DiffDaff - Compare Files, Folders And Web PagesDialog', 'Dialog']'

Where, '', u'DiffDaff - Compare files, folders and web pages', u'Internet Explorer_Hidden ', u'DiffDaff - Compare files, folders and web pages Dialog', 'Dialog' is the name of sotfware

In addition, using the command 'app.dialogs.print_control_identifiers()'to find out exactly what the position of the "About" button is, there is an output:

Button - '&About'   (L750, T388, R834, B411)
    '&About' '&AboutButton' 'Button3'

, (/ L750, T388,...). , ?

'Click'?

.

+5
1

pywinauto Application .

app.<DialogName>.<ControlName>.<method>(<params>)

app.Dialog.About.click()

, click_input() . click() WM_CLICK .

print_control_identifiers() :

<ControlType> - '<Name a la WindowText>' (<rectangle>)
                possible names which are most likely useful for object attribute access

:

app.window(best_match='Dialog', top_level_only=True).child_window(best_match='About').click()

pywinauto , __getattribute__.

+5

Source: https://habr.com/ru/post/1547382/


All Articles