<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Hello,</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
<br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">There was a question from my colleague, how do I select an element from system tray icon in Windows 7. I came up with the following code:</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
from ldtp import *</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">s=getobjectsize('pane0', 'btnNotificationChevron')</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">generatemouseevent(s[0] + s[2]/2, s[1] + s[3]/2, 'b1c')</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
wait(2)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">s1=getobjectsize('paneNotificationOverflow', 'btnMcAffee*')</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">generatemouseevent(s1[0] + s1[2]/2, s1[1] + s1[3]/2, 'b3c')</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
wait(2)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">getobjectlist('mnuContext')</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
selectmenuitem('mnuContext', 'mnuVirusScanConsole')</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
He asked me how do get to identify these objects, when I use <a href="http://uiautomationverify.codeplex.com/">UI Automation Verify</a>, I could not identify the object as the icon in sys tray disappears after I select something in the tool.</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
I explained him this what I did to find the object in a python prompt:</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">First used getojbectlist('pane0') to verify whether its the bottom panel and noticed 'Start' button was part of the output.</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Tried clicking all the objects one by one in the tray icon to see which one has all the hidden app icons and found 'Notification Chevron' button.</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">He asked me why do you use s[0] + s[2] / 2 ... I explained as: to click on the center of the widget, get the object size (x, y, width, height) then do x + width / 2, y + height / 2 and get the center point on the object and do left click (b1c).</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Once the app icons popup do right click on the object, which pops up the menu.</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Next question from him was, how did you found 'mnuContext' as the window name ?</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">I did getwindowlist() before right clicking the object and after that as well, with that I found one additional window name in the list which is 'mnuContext'.</p>
<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
Now you are all set for selecting the element from sys tray icon.</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">
Thanks</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Nagappan</p><div><br></div>-- <br>Linux Desktop (GUI Application) Testing Project - <a href="http://ldtp.freedesktop.org">http://ldtp.freedesktop.org</a><br>
<a href="http://nagappanal.blogspot.com">http://nagappanal.blogspot.com</a><br>