Ranorex

Tab Controls (without control names)

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython
View previous topic :: View next topic  
Author Message
James Hirst



Joined: 06 Dec 2006
Posts: 21
Location: UK

PostPosted: Wed Dec 06, 2006 7:42 pm    Post subject: Tab Controls (without control names)
Hi guys,

I'm scripting the windows display properties dialog.

Most of this is pretty stratight forward with the controlname functions but when they aren't present it gets a tad confusing. This is true in the case of the tabs (Settings, Screen Saver, Themes etc). I'm led to believe from looking at the forum that I should be using the element functionality to achieve this. Sound about right?

I'm not only a novice at Ranorex but also a novice with Python but can code in other languages.

Just seeking some direction here.

Thanks,
James
Very Happy
Back to top
View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Wed Dec 06, 2006 9:16 pm    Post subject:
The display properties dialog is an old windows control, it's not a .NET control so it has no control names.
You can only use the FormFindChildClassName and FormFindChildControlId functions to find a control in the form. You can also use the element functions to find the elements in the tab pages.

The following code finds and activates the 'Display Properties' dialog, reads and activates all tabs, searches the 'Display' element and reads the text of it.

Code: click into code to enlarge
...
form = Ranorex.FormFindTitle('Display Properties')
if form == 0:
    print 'Error: Form not found'       
    return 4
print '   Form found, form=' + hex(form)

print '--------------------------------------------------------------------'
print ' Searching and testing a tab control'
print '--------------------------------------------------------------------- '
print '   Searching tabControl1 by control name'
tabControl = Ranorex.FormFindChildClassName(form,'SysTabControl32')
if tabControl == 0:
    print 'ERROR: tabControl1 not found'
    return 5
print '      tabControl=' + hex(tabControl)

print '  Moving the mouse to the tab control'
Ranorex.MouseMoveToControl(tabControl)

selectedIndex = Ranorex.TabControlGetSelectedIndex(tabControl)
if selectedIndex != -1:
    print '   SelectedIndex=' + str(selectedIndex)
selectedText = Ranorex.TabControlGetSelectedText(tabControl)
if selectedText != None:
    print '   SelectedText=' + str(selectedText)

itemCount = Ranorex.TabControlGetItemCount(tabControl)
print '   ItemCount=' + str(itemCount)
for i in range(itemCount):
    text = Ranorex.TabControlGetItemText(tabControl,i)
    print '     Tabtext ' + str(i) + '=' + text
    Ranorex.TabControlSetSelectedIndex(tabControl,i)
    Ranorex.Sleep(1000)

element = Ranorex.ControlGetElement(form)
display = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_STATICTEXT, 'Display:', 'ComboBox')
if display == None:
    print 'ERROR: display not found'
    return 5
Ranorex.MouseMoveToElement(display)
print Ranorex.ElementGetValue(display)

Use RanorexSpy to get the control and element properties.

Jenö Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum