1

On the pywinauto documentation it says that you can click a radio button using the click method:

click method documentation

I have already had issues using the UIA backend, since it is different to win32. In this case, there seems to be no way to click a radio button.

I tried using a window specification:

    spec.window(auto_id='RadioButtonManualbackground').click()

AttributeError: Neither GUI element (wrapper) nor wrapper method 'click' were found (typo?)

It cannot find any method called click. I tried using toggle and check and those didn't work either.

I also tried clicking the radio button using the tree hierarchy:

    app.Dialog.Analysis.BackgroundCorrection.ManualBackgroundCorrection.click()

pywinauto.uia_defines.NoPatternInterfaceError

Again, this didn't work with toggle or check.

Is there support for clicking a radio button using UIA backend, and how do I do it?

Aric
  • 319
  • 7
  • 27

1 Answers1

2

This might be a bit confusing, but radio button wrapper has .select() method which uses SelectionItemPattern. I've found it in test_radio_button unit test.

Proper implementation should check all possible patterns and choose the working one. So I would consider it as a bug: filed issue #549. Thanks for reporting it!

P.S. You always have method .click_input() as a workaround. It performs the most realistic click with moving the cursor.

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
  • I'll try the `select()` method tomorrow. Does `click_input()` use mouse coordinates? If it does then I will hesitate to use it, since my automation program is supposed to be used on a variety of resolutions – Aric Aug 17 '18 at 21:15
  • 1
    `.click_input()` uses control's rectangle middle point so this is robust to changing resolution. The only aspect that can matter: it requires active desktop so the OS shall not be locked or RDP window shall not be minimized or disconnected. – Vasily Ryabov Aug 17 '18 at 22:49
  • Yes! sorry, forgot to accept. I used `.select()` in the end – Aric Aug 30 '18 at 13:12