I made a new Python sample WebPageTest.py to demonstrate how to automate a simple web page.
It's similar to the .NET sample RanorexVS2005Sample5.
The sample uses the Element functions to automate controls in Internet Explorer.
You can find the sample in the V0.9.3-Beta2 Version:
http://www.ranorex.com/download/Ranorex-0.9.3-Beta2.zip
Here are some useful tips:
Use the FormFind function to find the Internet Explorer application:
Code: click into code to enlarge
form = Ranorex.FormFindTitle('Microsoft Internet Explorer',Ranorex.MATCH_SUBSTRING);
Use the FormFindChildClassName function to find the address box:
Code: click into code to enlarge
addressBox = Ranorex.FormFindChildClassName(form, "Edit");
You can manipulate the address with the control functions:
Code: click into code to enlarge
Ranorex.MouseClickControl(addressBox);
Ranorex.ControlSetText(addressBox, 'http://www.google.com');
Ranorex.ControlSendKeys(addressBox, "{ENTER}");
Find the internet explorer control (within the form) with FormFindChildClassName and get the element object:
Code: click into code to enlarge
explorerControl = Ranorex.FormFindChildClassName(form, "Internet Explorer_Server");
explorerElement = Ranorex.ControlGetElement(explorerControl);
Use the ElementFindChild function to get the elements of the control and the element functions to automate the control:
Code: click into code to enlarge
# Find the search edit box
googleEditBox = Ranorex.ElementFindChild(explorerElement,Ranorex.ROLE_SYSTEM_TEXT, 'Search')
# Set the text of the search edit box
Ranorex.ElementSetValue(googleEditBox, 'Ranorex');
# Find the search button
googleSearchButton = Ranorex.ElementFindChild(explorerElement,Ranorex.ROLE_SYSTEM_PUSHBUTTO N, 'Search');
Ranorex.MouseMoveToElement(googleSearchButton);
# Press the search button
Ranorex.ElementDoDefaultAction(googleSearchButton);
Jenö Herget
Ranorex Team |