Upload
nguyencong
View
250
Download
1
Embed Size (px)
Citation preview
Open2Test.org
Open2Test Test Automation Framework (Web) for
SilkTest Workbench
Framework Architecture and Design
Version 1.0
November 2013
DISCLAIMER
Verbatim copying and distribution of this entire article is
permitted worldwide, without royalty, in any medium, provided
this notice is preserved.
Open2Test.org 2
Contents
1. Purpose ............................................................... 4
2. Framework Architecture ......................................5
2.1 Key components: .......................................... 5
2.2 Implementation: .......................................... 7
3. Functions ...................................................9
3.1 Main Functions ........................................... 9
3.2 Action Functions ........................................ 11
3.2.1 Perform Function ..................................... 11
3.2.2 Store/Check Function ................................. 13
3.2.3 Functions for setting object ......................... 14
3.2.4 Functions for Condition .............................. 15
3.2.5 Functions for Loop ................................... 16
3.2.6 Function for Wait: ................................... 16
3.2.7 Function Func_Clear: ................................ 16
3.2.8 Function Func_AttrVal ................................ 17
3.2.9 Function retrieve the value of a variable ............ 17
3.2.10 Function retrieve the value of an object ............ 18
4. Exceptions Handling and error Messages: ....................19
4.1 Function Keyword_Driver() ............................... 19
4.1.1 Invalid File Format Exception: ....................... 19
4.1.2 Keyword not supported for screencaptureoption Exception:
........................................................... 19
4.1.3 Keyword not supported Exception: ..................... 19
4.1.4 Condition Construct Exception: ....................... 19
4.1.5 Loop Construct Exception: ............................ 19
4.1.6: User Defined function Exception: .................... 19
4.2 Function GetValueObject(): ............................. 20
4.3 Function GetValue(): ................................... 20
Open2Test.org 3
4.4 Function Func_Perform() : ............................. 20
4.5 Function Func_ObjectSet(): ............................. 20
4.6 Function Func_StoreCheck(): ............................ 20
4.7 Function Func_AttrVal(): ............................... 21
Open2Test.org 4
1. Purpose
The purpose of the document is to detail about the navigation/flow of
the Open2Test Framework (Web) for SilkTest WorkBench
Open2Test.org 5
2. Framework Architecture
The following architecture is used for the proposed Open2Test framework for
Silk Test.
2.1 Key components:
The following files are the input files to the framework:
i. Object Repository
ii. Test Data
iii. Test Script
Following are the output we are getting throgh the framework execution:
i. Screenshots
Keyword Driver
Web Technology framework File
User
Defined Functions Test Reports
Test Data (From TAP)
Screen Shots
Master Test Script Object Repository
(From TAP)
Test Script (From TAP)
Open2Test.org 6
ii. Test Reports
This section explain the key components of the framework in detail.
1. Keyword Driver file
‘Keyword Driver’ file acts as a master driver, which fetches the
keywords from excel sheet and calls the respective actions. Also,
‘Keyword Driver’ would contain the function definitions of all the
generic (non-technology specific) functions such as Condition, loop,
wait, msgbox etc.
2. Web Technology Framework
‘Web Technology’ file would contain the function definitions of
‘Context’, ‘Perform’, ‘Check’ and ‘StoreValue’ keywords of Web
technology.
3. User Defined Functions file
‘User Defined Functions’ file would contain the function
definitions that are specific to the application under test.
Open2Test users write user defined functions to automate the test
steps that cannot be automated using predefined Open2Test keywords.
4. Object repository:
Object repository file created through TAP or created manually will
be integrated with the SilkTest during the execution:
The following format to be followed for this document:
Sno Object Name Object Type Parent Object Path
1 WebBrowser browser 0 /BrowserApplication
2 Google browser 0 //BrowserWindow
3 test textbox 1 //*[@id='usr_nm']
4 test1 link 1
//*[@innertext='Messages' and
@href='*//mmb.moneycontrol.*']
Object Name will be in any one of the object types supported by
Open2Test framework for Silk Test. For example, Browser;
List of the object types supported by Open2Test Framework for silk
test is attached in the section 6.Attachments
Open2Test.org 7
5. Test Data:
Test Data file will contain the Test Data to be used at run time: The
Format of the Data Table will be:
Data1 Data2 Data3 Data N
<data1-itr1> <data2-itr1> <data3-itr1> <dataN-itr1>
<data1-itr2> <data2-itr2> <data3-itr2> <dataN-itr2>
<data1-itr3> <data2-itr3> <data3-itr3> <dataN-itr3>
6. Test Script:
Automate Keyword Object Action Value
r <Keyword>
<Object Type>; <Object
Name>
<Action to be
performed>
List of all the keywords have been attached in the section
2.2 Implementation:
Open2Test components need to be associated with the Master test script
in ‘SilkTest Workbench’ by following the steps:
1. In SilkTest Workbench, create a .net script.
2. Navigate to the ‘Properties’ pane of the script.
3. Right click on the ‘Files’ node, and select the option ‘Add File’.
4. Associate the above mentioned files with the test script.
5. Right click on the ‘Application configuration’ node, and select the
option ‘Add Application configuration’.
6. Select Browser from Browser combobox in Add Application
configuration dialog.
7. Open the application to test in selected browser.
8. Click the ‘Select Application’ in Add Application configuration
dialog.
9. Select the application to test in Select Application dialog.
10. Change the ‘Locator:’ Text Field value to /BrowserApplication.
11. Click ‘Ok’
12. Save the script.
Once associated, individual test scripts need to make a call to Master
Test Script, containing the ‘Active Data’ names of the ‘Keyword Test
Script’, Test_Data_Object and ‘External Test Data’ using ‘RunScript’
command as below:
Imports SilkTest.Ntf.XBrowser
Open2Test.org 8
Public Module Main
Public Sub Main()
Dim args As New Dictionary(Of String, Object)
Dim test As String
args("KTC") = "KTC"
args("AData") = "Test_Data_1"
args("AObject") = "Test_Data_Object"
args("Rpath") = "C:\"
Workbench.RunScript("O2T_Framework_IE", args)
End Sub
End Module
Keyword Driven Framework, Web Technology and User Defined function is added
as new .Net script in same project with Application configuration as above
Master test script.
Note: In the above script, ‘Keyword_Test_Case’ (KTC), Test_Data_Object and
‘Test_Data_1’ correspond to the ‘Active_Data’ names of the keyword test case,
external object information and external test data. All the Input files –
Test Script, Object repository, Data Table should be registered as the active
data of the Silk Test.
Open2Test.org 9
3. Functions
3.1 Main Functions
Name of the function: Keyword_Driver()
Description: This is the main function, which interprets the keywords and
stores the values in the columns in the respective variables.
Parameters: Null
Assumptions: The automation script is present in the external spreadsheet
located in the particular folder.
Variables:
a) RowCount– This variable holds the row count.
b) Kdata– This variable holds the reference to the external script sheet.
c) Kdatarow– This variable holds the reference to the specified row.
Functionality:
The Keyword_Driver reads the first column, Based on whether the value is “r”
or not in the first column it calls the Func_FetchData which reads the value
in the different column and returns the value to a variable. Depending on the
keyword passed in the second column
Keyword_Driver calls different functions.
• Based on the value in the variable keyword (second column), the
Keyword_Driver function calls different functions.
• If the value is ‘perform’, ‘storevalue’ or ‘check’, then it calls the
Keyword function of the respective Keyword. For example, if the value
is ‘report’, it will call Func_Report ()
• The following is the list of keywords supported for this function
Context : Set the context to the full hierarchical Path for the object
on which some action is to be performed.
Perform: to perform a set of operations
check: to check any property of a particular object into a variable
storevalue: to store any property of a particular object into a
variable
launchapp: To launch the application
msgbox: To display a message
wait: To instruct the process to wait for the given time (in
millisecond)
Screencaptureoption: To capture the screenshots only for the keywords
specified
Condition: Compare the values and perform the action accordingly.
Endcondition: Execution of condition starts from ‘Condition’ Keyword to
‘EndCondition’ Keyword.
Assignvalue: Assign the Value to the variable
Open2Test.org 10
Loop: For repetitive execution of statements
Endloop: For executing statements from Loop
Screencapture: Captures screens for actions
Importdata: To import the Test Data from Data sheet
Callfunction: To call the user defined functions
i. Name of the Function:Func_FetchData
Description: This is the function, which access test script and stores the
values of the columns of the test script in the respective variables.
Parameters: Active Data Row object of keyword test script
Variables:
a) Keyword – This variable is used to store the value in the second column.
b) arrObject – This variable is used to store the value in the third column.
c) arrAction1 – This variable is used to store the value in the fourth
column.
d) arrAction2 – This variable is used to store the value in the fifth
column.
Functionality:
function reads the values in the second, third, and fourth columns in the
data sheet and stores the values into the variables.
ii. Name of the Function: Update_Report
Parameter: status
Variables:
strTime – To store the current time in hour – Min – second format
Functionality:
The function updates the report for the Test script execution.
Open2Test.org 11
3.2 Action Functions
3.2.1 Perform Function
Name of the function: Func_Perform()
Description: This function performs the set of actions on the required object
in the AUT.
Parameters:
a)arrAction1(0)– This variable holds the particular action to be performed on
the specified object.
b) arrAction1(1)– This variable holds the value that needs to be used while
performing a specified action on the object.
c) arrObject(0)– This variable holds the object type.
d) arrObject(1)-This variable holds the object name.
Assumptions: Specified object Exist on the AUT.
Functionality:
Based on the values in arrAction1(0)– Func_Perform different actions on
objects. If the value is:
1. set: Based on the values in arrAction1(1) the function performs the set
actions on objects. If the value in the variable arrAction1(0) is:
a. set: Performs set operation on the object
2. click: Performs click operation on the object
3. doubleclick: Performs double click operation on the object
4. check: Performs check operation on the object. For example: checks the
checkbox specified
5. uncheck: Performs uncheck operation on the object. For example: unchecks
the checkbox specified
6. select: Performs select operation on the object. For example: selects the
specific value defined in the arrAction1(1) from the list box
7.domclick: Performs click operation on the object using the DOM API. For
example: Click on the specific listbox
Defined in the arrObject(1)
8. domdoubleclick: This double click on the object specified using the DOM
API.
Open2Test.org 12
9. Focus: This sets focus on specified object.
10. Highlight: This high light the button with the specified color.
11 UnHighlight: Restores the original foreground and background colors.
12. Navigate: Navigate the main document to the URL.
13. Close: Closes the modal browser dialog, tab of the browser or the browser
if it is the last browser.
14. Forward: Goes forward in the history
15. Reload: Reload the main document
16. CloseOtherTabs: Close other tabs except specified.
17. CloseTab: Close other tabs except specified..
18. opentab: Open the specified url on the tab.
19. SelectTab: Select the specified tab.
20. Toggle: Toggle the state of the check box. If the checkbox is checked it
is unchecked and vice versa.
21. Submit: Submits the entered data to the server by sending the ‘submit’
key.
22. Unselect: Unselect the specified item from the List Box.
23. Multiselect: Select the specified items from the List Box.
24. Type: Performs type operation on the object
Constraints:
The following actions will not be supported by Open2Test Framework:
perform dialog select For Data sheet input
perform dialog select
For Environment
Variable(#Var)
perform tab domclick
perform tab opentab
For Environment
Variable(#Var)
perform tab selecttab
For Environment
Variable(#Var)
perform pushbutton domclick
perform pushbutton domdoubleclick
perform pushbutton highlight
For radio button ‘Select’ syntax will be:
perform|radiobutton;objectname|select
Open2Test.org 13
3.2.2 Store/Check Function
Name of the function: Func_StoreCheck
Description: This function is used to store into a variable or Check any
property of a particular object
Parameters:
a) arrAction1(0)– This variable is used to store the property of the object.
b) arrAction1(1)– Holds the expected property value of the object IF IT’S A Check keyword or the Variable name used to store the actual property
value if it is a StoreValue keyword.
Assumptions: None
Variables:
a) varname– This variable is used to store the actual value of the property
when the keyword is Storevalue.
b) actVal– This variable is used to store the actual value of the property
value.
d) expVal- This variable is used to hold the expected property value
Functionality:
Based on the values in Keyword the function performs different actions. It
Can be Check Or StoreValue and also on the arrAction1(0).Example :If the
arrAction1(0) is
i. storevalue
1) itemcount: “items count” property of the object is stored in the variable name
specified in the for the column of the sheet for storevalue keyword.
3) getcell: The value of the cell specified is stored in the variable defined for storevalue keyword.
4) text: “text” property of the object is stored in the variable name specified in the fourth column in data sheet.
5) selected: “Selected” property of the object is stored in the variable name specified in the fourth column of the data sheet.
6) visible: “visible” property of the object is captured and converted to the Boolean data type. The negation of this value is then stored in the
variable name specified in the fourth
7) checked: “checked” property of the object is captured and converted to the Boolean data type. The negation of this value is then stored in the
variable name specified in the fourth
Open2Test.org 14
8) allowsmultiselect: Stores the property Allowsmultiselect value in the name specified in the fourth column of the data sheet from list box.
9) itempresent: Returns Boolean value based on specified item exist in the list box.
The syntax of the framework will be :
storevalue| objectype ; objectName|itempresent:<true/false>|variable
Name
10) selecteditem: Capture the selected item in a variable from
list box.
11) columncount: Stores columncount property value in a variable.
12) rowcount: Stores the rowcount property value in a variable.
13) value: Stores the value property of the Textbox in a variable.
14) exists: Stores the Exist property value in a variable.
ii. Check
1) text: Check specified text is displayed in the element.
2) allowsmultiselect: Check specified list box allow selecting the multiple items.
3) Itempresent: Check specified item exists in the list box.
Check| objecttype; objectName|itempresent:<true/false>|variable Name
4) selecteditem: Check specified item is selected in the list box.
5) selected: Check specified Radio button is selected.
6) columncount: Check table contains the specified column count.
7) rowcount: Check table contains the specified row count.
8) value: Check the Text Filed contains the specified value.
9) itemcount: The “itemcount “ property of the object compared with the expected
value specified and writes the report statement for the check
keyword.
10) exists: Check the specified object is exist
11) visible: Check the specified object is visible
12) getcell: Check the specified value is displayed in the mentioned
cell.
13) itemcount: Check specified number of items exists in the list
box.
14) checked: Check the check box is checked.
3.2.3 Functions for setting object
Name of the function: Func_Context()
Description: This function is used to highlight selected object.
Parameters:
a) arrObject – this variable holds the value of the object name and type.
Assumptions: The AUT is already up and running.
Open2Test.org 15
Functionality:
• Based on the values on arrAction1(0) this function will set the context
on different objects. If the value is:
i) Page: Sets the highlight on the Page defined
ii) Dialog: Sets the highlight on the Browser defined
Name of the function: Find_Obj()
Description: This function sets the parent and child objects.
Parameters: arrObj is an array of object names and intRowCount is the current
Row number. Assumptions: NA
Functionality:
This function sets the parent and child objects of any one of the following
type
Browser
dialog
button
checkbox
element
form
link
listbox
radiobutton
table
textbox
pushbutton
ComboBox
image
Textarea
Tab (Tab refers to the window tab. Tabs in the web page will be identified as
element)
Tablerow
TableTextBox
Variables: NA
3.2.4 Functions for Condition
Name of the function: Func_Condition
Description: This function is used to evaluate the expression according to
the inputs given in
Parameters:
arrObject(0)-Holds the Value to be compared with arrObject(2)
arrObject(1)-Holds the operator
Assumptions: The AUT is already up and running.
Functionality:
Based on the values passed in the third column this function will execute the
set of code:
Variables:
val1: Holds the first value to be compared
Open2Test.org 16
oper: Holds the operator (Available Operators: "equals", “not”,
“greaterthan”, “lessthan”
val2: Holds the second value to be compared
3.2.5 Functions for Loop
Name of the Function: Func_Eloop
Description: Repeats a group of statements a specified number of times from
the row Loop to Endloop.
Parameters:
a) ArrObject1: This variable holds the value of the third column in the data
table.
Assumptions : If the number of times to be looped is not specified, by
default this number is taken as the number of active rows in Action1 sheet
of Datatable.
Variables: lpno: Stores the loop number of the script during execution
Functionality: Repeats a group of statements a specified number of times from
the row Loop to Endloop.
3.2.6 Function for Wait:
Name of the function: Func_wait()
Description: This function is used for synchronization with the application.
Parameters:
a) ArrObject1: This variable holds the value of the third column in the data
table.
Assumptions: NA
Variables: NA
Functionality:
Based on the value of the arrAction1 the script wait till the specified time
in seconds.
3.2.7 Function Func_Clear:
Function name : Func_Clear
Open2Test.org 17
Description : This function is used to clear the array object.
Assumptions : NA
Variables: NA
Functionality:
This function is used to clear the array object.
3.2.8 Function Func_AttrVal
Function : Func_AttrVal
Parameters : The property to be captured and expected value
Description : This function is used to get the property
value of object.
Assumptions : AUT is already up and running.
Variables:
actVal: This variable is used to store the actual value of the
property value.
Functionality:
This function is used to get the property value of object.
3.2.9 Function retrieve the value of a variable
Function : GetValue
Parameters : 'strCellData'containing the value passed from other
functions goes as a parameter
Description : This function is used to retrieve the value
from any variable.
Assumptions : NA
Variables: NA
Functionality: This function is used to retrieve the value
from any variable.
Open2Test.org 18
3.2.10 Function retrieve the value of an object
Function : GetValueObject
Parameters : 'strCellData'containing the value passed from other
functions goes as a parameter
Description : This function is used to retrieve the
attribute value of object from Object Repository.
Assumptions : NA
Variables: NA
Functionality: This function is used to retrieve the
attribute value of object from Object Repository.
Open2Test.org 19
4. Exceptions Handling and error Messages:
4.1 Function Keyword_Driver()
4.1.1 Invalid File Format Exception:
If the file format given in Action2 Column (for ‘screencapture’ and
‘screencaptureoption’ Keywords) is invalid then the following error will be
thrown
"screencapture file format specified is Invalid. Please check the value in
Action2 column entered in the row number " <rownumber>
4.1.2 Keyword not supported for screencaptureoption Exception:
If the screencaptureoption Keyword contains the actions other than ‘perform’,
‘context’, ‘check’ or ‘storevalue’ the following error will be thrown:
Screen Capture operation doesn't support the keyword (<<Unsupported
Keyword>>) entered. Please check the keyword entered in the row number <r.no>
4.1.3 Keyword not supported Exception:
For any unsupported Keyword call, the following error will be thrown:
“Keyword not supported. Please check the keyword entered in the row number”
<row_num>
4.1.4 Condition Construct Exception:
For any missing ‘endcondition’ for ‘condition’ keyword, throw the following
error:
"Condition Construct Exception occured. Please check that every Condition
keyword has its corresponding endCondition keyword."
4.1.5 Loop Construct Exception:
For any missing ‘endloop’ for ‘loop’ keyword, throw the following error:
"Loop Construct Exception occured. Please check that every Loop keyword has
its corresponding endLoop keyword."
4.1.6: User Defined function Exception:
If the given call function name is not found , the following exception will
be thrown:
User Defined Function mentioned in the row <rowno> does not exist. Please
check the Function Name.
Open2Test.org 20
4.1.7: Operation not supported:
If the Operation given for the condition is not correct one:
Operation not supported for the condition specified. Please check the
operation entered in the row number <<RowNo>>
4.2 Function GetValueObject():
If the given environment variable for an object is not available, throw the
following exception:
"Variable does not exist. Please check the entered variable name
<Variable> in the row number <row number> "
4.3 Function GetValue():
If the given environment variable for an variable is not available, throw the
following exception:
"Variable does not exist. Please check the entered variable name <Variable>
in the row number <row number> "
4.4 Function Func_Perform() :
For any actions that cannot be supported by ‘Perform’ Keyword throw the
following exceptions,
" Action not supported. Please check the action entered in the row number
<<rownum>>”
4.5 Function Func_ObjectSet():
For any object that is not supported by SilkTest_web framework, throw the
following exception
" Object type not supported. Please check the object type entered in the row
number <row number>”
4.6 Function Func_StoreCheck():
Anny keyword other than ‘check’ and ‘storevalue’ while calling the function
throw the following error message
"Keyword is not supported. Please check the keyword entered in the row number
<row number>”
Open2Test.org 21
4.7 Function Func_AttrVal():
For any other attribibutes that is not supported for ‘check’ and ‘storevalue’
keywords throw the following exception
" Object Property not supported. Please check the property for the object
entered in the row number <row number>”
All the exceptions which were not explicitly mentioned in the above mentioned
section, SilkTest error messages will be thrown
C O P Y R I G H T
This library is free software; you can redistribute it and/or modify it under the terms of the
GNU Library General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.