Web test - Samples

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

Web test - Samples

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

Hi,
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.

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

Post by admin » 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:

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: 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.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: 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');
Ranorex.MouseMoveToElement(googleSearchButton);
# Press the search button
Ranorex.ElementDoDefaultAction(googleSearchButton);
Jenö Herget
Ranorex Team

balu_r77
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.