Silk Test Questions and Answers

1. Which Type of Functional Test Cases should be automated?
a) Regression Bugs : As the functionality is already present in the software
b) Repetitive Test Cases : Similar Type of test cases which if one is automated leads to easier automation of other test cases
c) Data Driven : When repetitive type of Data inputs are required for test cases
d) Easy to automate : Test Cases which are easy to automate thru Silk/WinRunner
e) Data base testing: Which needs input from database or takes output from database for validation.
f) Acceptance Tests of Builds

2. Why Functional Automation?
Automation is done to reduce repeated and redundant testing. Automation maintains a single standard of quality for your application over time — across releases, platforms, and networks.

3. Steps to Automate through Silk?
•Creating a test plan
•Recording a test frame
•Creating Test cases
•Running Test cases and interpreting their results

4. Why Silk?
Silk is an object-oriented fourth-generation language (4GL) using 4Test language. Silk is used for testing GUI applications, C/S applications, web applications and web browsers.

5. What Host and agent do?
SilkTest host software
•The SilkTest host software is the program you use to develop, edit, compile, run, and debug your Silk scripts and test plans.
The Agent
•The 4Test Agent is the software process that translates the commands in Silk scripts into GUI-specific commands.

6. What Type of Data Types Silk Uses?
•Built-in Data Types
ANYTYPE
A variable of type ANYTYPE stores data of any type, including user-defined types.
BOOLEAN
A variable of type BOOLEAN stores either TRUE or FALSE.
DATACLASS
The legal values of the DATACLASS type are the names of all the 4Test classes, including user-defined classes
C Data types
Char•Int•Short•Long•unsigned char•unsigned int•unsigned short•unsigned long•Float•double
User Defined Data Types
example: type FILE is LIST OF STRING
type COLOR is enum
red
green

7. What are Various Types of 'Built in Functions' in Silk?
•Application state
•Array manipulation
•Char/string conversion
•Data type manipulation

8. What are Various Types of Files in Silk?
•Test Frames
•Include Files
•Test Scripts
•Test Plans
•Suite Files
•Option Set
•Result File

9. How Window declarations are useful?
•Declarations specify logical names
•Declarations can encapsulate data and functions

10. What are the stages of recording Window declaration?
Two stages for Recording window Declaration:
•Record the window declarations for the main window (including its menus and controls).
•Bring up each dialog one at a time and record a declaration for each.

11. What are the stages of recording Window declaration?
Two stages for Recording window Declaration:
•Record the window declarations for the main window (including its menus and controls).
•Bring up each dialog one at a time and record a declaration for each.
•Every window declaration consists of a class, identifier, and one or more tags. The class cannot be changed
•The window declaration maps the object’s logical, platform-independent name, called the identifier, to the object’s actual name, called the tag. Identifier can be changed.

12. What are the various types of Tags?
•Caption
•Prior text: Prior text tags begin with the ^ character.
•Index: Index tags begin with the # character.
•Window ID: Window ID tags begin with the $ character.
•Location: Location tags begin with the @ character.

13. What Multitags used for?
This is particularly an issue in situations where captions change dynamically, such as in MDI applications where the window title changes each time a different child window is made active. When running test cases, The Agent tries to resolve each part of a multiple tag from top to bottom until it finds an object that matches.

14. How Errors are handled in Silk?
a) Default Error Handling
If a test case fails (for example, if the expected value doesn’t match the actual value in a verification statement), Silk Test by default calls its built-in recovery system, which:
- Terminates the test case
- Logs the error in the results file
- Restores your application to its default base state in preparation for the next test case. These runtime errors are called exceptions. They indicate that something did not go as expected in a script. They can be generated automatically by Silk Test, such as when verification fails, when there is a division by zero in a script, or when an invalid function is called.
b) Explicit Error Handling
However, suppose you don’t want Silk Test to transfer control to the recovery system when an exception is generated, but instead want to trap the exception and handle it yourself. To do this, you use the 4Test do...except statement.
c) Programmatically logging an error
•Some of the test cases passed, even though an error occurred, because they used their own error handler and did not specify to log the error. If you want to handle errors locally and generate an error (that is, log an error in the results file), you can do any of the following:
- After you have handled the error, reraise it using the reraise statement and let the default recovery system handle it
- Call any of the following functions in your script:

Function Action
LogError (string) Writes string to the results file as an error (displays in red or italics, depending on platform) and increments the error counter. This function is called automatically if you don’t handle the error yourself.
LogWarning (string) same as LogError, except it logs a warning, not an error.
ExceptLog ( ) Calls LogError with the data from the most recent exception.

15. What are Custom Objects and how are they useful?
•Silk designates an object as custom if it is not an instance of a built-in class.
•Custom classes enable an application to:
- perform functions specific to the application
- enhance standard class functionality
- be maintained and extended easily by the developers
•All custom objects default to the built-in class CustomWin

16. How Custom Objects can be used?
•Mapping to Known Classes
•Procedure to Class Map a Custom Object
1. Select Record / Window Declarations
2. Place the cursor over the custom object
3. Press Ctrl-Alt. The Record Window Declaration dialog appears
4. Click Class Map. The Class Map dialog appears
5. Select the corresponding standard class
6. Click Add
7. Click OK
8. Click Resume Tracking.

Adding User-Defined Methods:
Functions specific to a window are called methods. A method is a series of commands that perform a task.
- Methods can have data passed to them
- Methods can return a value

•To create a method specific to a window, define the function within the declaration of the window. The function automatically becomes a member of that window, or a member function.

Methods Available to an Entire Class
Some methods may be applicable for any instance of a class, not just for a particular object

Normal function syntax applies:
- Scope is local (to the class)
- May return or take parameters

Use the following structure to define a new class:
winclass new_sub_class_name : class_name

•Derive your new class from what is the logical parent class of the custom class.

•To add the new method for a class, place it within this class definition.

•Since you are defining your methods at the class level, there may be multiple instances of the class in your application. When referring to the object within your method, instead of ‘hard coding’ a particular instance refer to it generically with the keyword this.

•‘this’ refers to the specific instance (object) that the method will operate against at runtime. It is an object oriented technique that may be used when defining methods within a window class declaration.

Steps to implement:
- Derive a new class for each custom class
- Add methods to operate on instances of the class
- Declare objects (or modify existing declarations) of the custom class to be instances of your new defined class.

Calling DLL functions
•A DLL (Dynamic Link Library) is a binary file containing functions. An application is dynamically linked to this file at run time:
- Enabling the application executable to be smaller
-Allowing multiple applications to share the same set of functions from a single source
•You can access DLL functions, which are either:
- Standard platform API calls
-Application specific functions
•These DLL functions are found in several files, including:
- Kernel32.dll
- Gdi32.dll
User32.dll

How to call Dll functions?
•Declare the name of the dll where the function is found
•Declare the name of the function, its return type (if any) and its parameter list (if any)
•Declare any specific data types used by the function
•Declare any constants used by the function
•Call the function from within a SilkTest script.
dll “user32.dll”
INT MessageBox (HWND hWnd, LPCSTR sText, LPCSTR sTitle, UINT uFlags)
Passing arguments to DLL functions
•Calling DLL functions written in C requires you to use the appropriate C data types:
- If the function uses C type BOOL, substitute type INT
- Pass string variable (STRING) for a pointer to a character(CHAR*)
- Pass array or list of the appropriate type for a pointer to a numerical array
-Pass a Silk record for a pointer to a record

•Many applications store part of their functionality in one or more dynamic libraries.

•Declare the DLL normally, but use the inprocess keyword before the function declaration in the DLL you are calling.
dll “C:\MyPrograms\circle.dll”
Inprocess INT GetRadius(HWND hWnd)


17. Why do we use appstates in Silk?
a) An application state is typically used to put an application into the state it should be in at the start of a test case.
Example:
appstate MyAppState () basedon MyBaseState
// Code to bring the application to the proper state...

appstate MyBaseState ()
// Code to bring the application to the base state...

18. Which silk function opens the desired file on the host system? Give example
FileOpen function
Example Syntax :-

// output file handle
HFILE OutputFileHandle
FILESHARE fShare
// now open the file
OutputFileHandle = FileOpen ("mydata.txt", FM_WRITE, fShare)

19. Which function in Silk would you use to connect to database and give its syntax/example?
DB_Connect function
Example: -
Hdatabase hdbc
hdbc = DB_Connect ("DSN=QESS;SRVR=PIONI;UID=sa;PWD=tester")

20. Which function in Silk would you use to query database and give its syntax/example?
DB_ExecuteSql function
Example: -
hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM emp")

21. How would you ensure exception handling in Silk test script?
Using “Do…. Except” statement. The do...except statement allows a possible exception to be handled by the test case instead of automatically terminating the test case. It Handles (ignores) an exception without halting a script.

22. What is the use of “Spawn” and “Rendezvous” in silk test?
a) Spawn -: The purpose of the spawn is to initiate Concurrent operation on Multiple Machines.
b) Rendezvous -: Blocks execution of the calling thread until all threads that were spawned by the calling thread have completed.

23. What is DefaultBasestate and why do we use it?
Silk Test provides a DefaultBaseState for applications, which ensures the following conditions are met before recording and executing a test case:
i. The application is running
ii. The application is not minimized
iii. The application is the active application
iv. No windows other than the application’s main window are open

Example: -
Here is a sample application state that performs the setup for all forward case-sensitive searches in the Find dialog:

appstate Setup () basedon DefaultBaseState
TextEditor.File.New.Pick ()
DocumentWindow.Document.TypeKeys ("Test Case")
TextEditor.Search.Find.Pick ()
Find.CaseSensitive.Check ()
Find.Direction.Select ("Down")

24. When do we use Appstate none?
a) When we do not want to have our test case any base state.
b) If your test case is based on an application state of none or a chain of application states ultimately based on none, all functions within the recovery system are not called. For example, SetAppState and SetBaseState are not called, while DefaultTestCaseEnter, DefaultTestCaseExit, and error handling are called.

25. What do the following commands do in the Debugging techniques: -
a) Step Into command: use Step Into to step through the function one line at a time, executing each line in turn as you go.
b) Step Over command: use Step Over to speed up debugging if you know a particular function is bug-free.
c) Finish Function command: use Finish Function to execute the script until the current function returns. SilkTest sets the focus at the line where the function returns. Try using Finish Function in combination with Step Into to step into a function and then run it.

26. What Would you do when you get the following error while executing your script Error: Window 'name' is not enabled
There are 2 ways to achieve this –
a) To turn off the verification globally, uncheck the Verify that windows are enabled option on the Verification tab in the Agent Options dialog (select Options/Agent).
b) Turn off the option in your script on a case by case basis, add the following statement to the script, just before the line causing the error: Agent.SetOption(OPT_VERIFY_ENABLED, FALSE)
Add the following line just after the line causing the error: Agent.SetOption(OPT_VERIFY_ENABLED, TRUE).This means SilkTest will execute the action regardless of whether the window is enabled.

27. How custom objects are mapped in Silk?
There are two ways to map custom objects to standard classes
a) While recording Window declaration Custom Win class can be mapped to Standard class. There is a button called Class Map on the declaration window. On clicking this button Class Map Window appears where you can physically map.
b) In scripts while writing you can go to Menu Options and select Class Map

For more software testing definitions, please go here

7 comments:

  1. Hi Munish,

    I have a question for you.
    How to type in the data at the time you are running the testcase?

    Regards,
    Nghia

    ReplyDelete
  2. Hi Munish,

    I have question regarding insert statement (into Sql-Server) using variables.

    I coded the following statement:
    hstmnt = DB_ExecuteSql (hdbc, "INSERT INTO SCC_Errors_Statistics (Error_Type , Error_Detailes, Robot_Name , Monitor_Name , Monitor_Start_Time , Error_Time , Error_On_Page ) VALUES (errortype, error_messages_list, robot_name, monitor_name, StartMonitorTime_SQLformat, ErrorTime_SQLformat, StepName)")

    Where the values are variables.

    I got the following error message:
    Error: (42000) [Microsoft][ODBC SQL Server Driver][SQL Server]The name "errortype" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted

    I tried several syntax but all failed with syntax error.

    Can you please advice what is correct syntax of insert statement (into Sql-Server) using variables?

    Thanks in advanced.

    Regards,
    Moshe.

    ReplyDelete
  3. Hi Munish,

    I have question regarding insert statement (into Sql-Server) using variables.

    I coded the following statement:
    hstmnt = DB_ExecuteSql (hdbc, "INSERT INTO SCC_Errors_Statistics (Error_Type , Error_Detailes, Robot_Name , Monitor_Name , Monitor_Start_Time , Error_Time , Error_On_Page ) VALUES (errortype, error_messages_list, robot_name, monitor_name, StartMonitorTime_SQLformat, ErrorTime_SQLformat, StepName)")

    Where the values are variables.

    I got the following error message:
    Error: (42000) [Microsoft][ODBC SQL Server Driver][SQL Server]The name "errortype" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted

    I tried several syntax but all failed with syntax error.

    Can you please advice what is correct syntax of insert statement (into Sql-Server) using variables?

    Thanks in advanced.

    Regards,
    Moshe.

    ReplyDelete
  4. Hi Munish,

    Can u please help on runtime class mapping?

    Thanks

    ReplyDelete
  5. Hi Moshe,
    try this and reply if it helps

    hstmnt = DB_ExecuteSql (hdbc, "INSERT INTO SCC_Errors_Statistics (Error_Type , Error_Detailes, Robot_Name , Monitor_Name , Monitor_Start_Time , Error_Time , Error_On_Page ) VALUES (" + errortype + " , " + error_messages_list + " , " + robot_name + " , " + monitor_name + " , " + StartMonitorTime_SQLformat + " , " + ErrorTime_SQLformat + " , " + StepName + ")")

    ReplyDelete
  6. Hi Munish,
    When i took a window declaration of a page, the locator of 'server name label' is getting server name itself.
    JLabel ServerName
    Locator "@Caption="s123"
    In this case server name is 's123' which gets changed when i connect to different server. I want to verify this server name on sumary page.I am using open agent. Can you please help me ?
    Thanx

    ReplyDelete
  7. HI munish,

    What's syntax of test case in silk test ?

    ReplyDelete