Understanding Selectors in Detail

selector

#1

I am having trouble understanding how to understand selectors. Here is an example. I have a test robot on my laptop that opens and manipulates excel. I found that sometimes excel would open in odd shapes and UI elements would be hidden so the robot would throw an exception. In order to make sure that excel was always fully opened I created a macro to maximize it. This required saving as an xlsm instead of xls. So I thought all I’d have to do is go into each selector that said xls and change it to xlsm. Wrong. It broke everything. So I compared a target that was before the change with the same target collected through “indicate on screen” after the change. I’d really like to know where there is some documentation on what each of these mean so I can create better less fragile selectors. Is there such documentation?

BEFORE (note rows 3,4,5)
<wnd app='excel.exe' cls='XLMAIN' title='InvestmentDaily.xls - Excel' />
<wnd cls='MsoCommandBar' title='Ribbon' />
<wnd cls='MsoWorkPane' title='Ribbon' />
<wnd aaname='Ribbon' cls='NetUIHWND' />
<ctrl name='Ribbon' role='property page' />
<ctrl name='Lower Ribbon' role='pane' />
<ctrl name='Home' role='property page' />
<ctrl name='Clipboard' role='tool bar' />
<ctrl name='Copy' role='grouping' />
<ctrl name='Copy' role='drop down button' />

AFTER (note row 2 replaces the previous 3,4,5) The only change was to save as XLSM and add the macro
<wnd app='excel.exe' cls='XLMAIN' title='InvestmentDaily.xlsm - Excel' />
<wnd cls='NetUIHWND' idx='2' />
<ctrl name='Ribbon' role='property page' />
<ctrl name='Lower Ribbon' role='pane' />
<ctrl name='Home' role='property page' />
<ctrl name='Clipboard' role='tool bar' />
<ctrl name='Copy' role='grouping' />
<ctrl name='Copy' role='drop down button' />


#2

Hi @billpennock, did you solve this? I am encountering similar problem. Well, for my case, I use a 2nd monitor and I get different sets of selectors depending on where I display the excel. The same with yours – one liner cls replaces a three-liner cls. Thanks in advance!

******1st monitor / main monitor**
<wnd cls='NetUIHWND' idx='2' />
<ctrl name='Ribbon' role='property page' />
<ctrl name='下リボン' role='pane' />
<ctrl name='挿入' role='property page' />
<ctrl name='テーブル' role='tool bar' />
<ctrl name='ピボットテーブル' role='push button' />


******2nd monitor**
<wnd cls='MsoCommandBar' title='Ribbon' />
<wnd cls='MsoWorkPane' title='Ribbon' />
<wnd aaname='Ribbon' cls='NetUIHWND' />
<ctrl name='Ribbon' role='property page' />
<ctrl name='下リボン' role='pane' />
<ctrl name='挿入' role='property page' />
<ctrl name='テーブル' role='tool bar' />
<ctrl name='ピボットテーブル' role='push button' />