Web test - Samples

Class library usage, coding and language questions.
Posts: 4
Joined: Wed Jul 19, 2006 1:04 pm

Web test - Samples

Post by balu_r77 » Mon Aug 21, 2006 1:09 pm

I was trying to test a webpage, and found that the control descriptions can not be used to recognise the objects.After reading through some posts in the forum, i understood that i need to use the element properties for that.Could it be possible that a sample script written in Python be made available for web testing.I saw one for C#,but could not get to understand that too much.It would be very helpful if a sample script is available.

Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Tue Aug 22, 2006 11:54 am

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:


Here are some useful tips:

Use the FormFind function to find the Internet Explorer application:

Code: Select all

form = Ranorex.FormFindTitle('Microsoft Internet Explorer',Ranorex.MATCH_SUBSTRING);
Use the FormFindChildClassName function to find the address box:

Code: Select all

addressBox = Ranorex.FormFindChildClassName(form, "Edit");
You can manipulate the address with the control functions:

Code: Select all

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: Select all

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: Select all

# 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_PUSHBUTTON, 'Search');
# Press the search button
Jenö Herget
Ranorex Team

Posts: 4
Joined: Wed Jul 19, 2006 1:04 pm

Post by balu_r77 » Wed Aug 23, 2006 5:32 am

Thank you very much.This could be very helpfull.I will use the Beta that you have provided.