Вы находитесь на странице: 1из 5

http://www.exforsys.

com/content/view/248/288/

1. How do I add steps to DefaultBaseState?

The easiest method is to add a BaseState () method to the main window of the
application. That's the one that wMainWindow is set to. If you define this
method, it will be executed at the end of DefaultBaseState (). Suggestion: By
using GetTestCaseState (), you can make your method behave differently
depending on whether the testcase is starting or stopping. This function will
tell you whether the testcase is starting or stopping.

Back to Top
Q2. Where can I find all the methods for a class?

Use the Library Browser. Its invoked by choosing Help-->Library Browser from
the SilkTest menu. Select the class tab, then select the class you want to
view. The methods for the class appear in the right panel. You can click on a
method and view its syntax. If you check the box marked Show Inherited, all
the methods from the ancestor classes will be shown. Its major disadvantage
is that you can't copy from it.

Back to Top
Q3. Why don't methods defined in a derived class inherit ?

When you create a class using winclass MoveableWin : MoveableWin, you're


actually deriving a new class which has the same name as the original class.
All objects automatically become instances of the new derived class.
However, other derived classes, such as DialogBox in this case, have already
been inherited from the original MoveableWin. This happened at startup and
can't be changed. Therefore, any methods you added to the inherited
MoveableWin class will not be available for use by DialogBox objects.

winclass MoveableWin : MoveableWin


Close ()
// Steps to close windows
window DialogBox Test
Example:
tag "Test"
parent MyApplication
main ()
Test.Close ()
The DialogBox "Test" will not use the new Close method defined
Notes:
above, even though DialogBox inherits from MoveableWin.
File: Download this file
Back to Top
Q4. How can I change test frames in the middle of a testplan?

First you need to understand optionsets. This feature lets you save your
configuration in a file. The configuration includes your Agent Options,
Runtime Options and Class Mappings. The feature is very useful when you try
to open your test frame on a new machine. The optionset brings all the
settings from one machine to another, including the test frame. This is also
very useful for a team.

Within SilkOrganizer, you can use the optionset command, which changes the
current optionset on the fly during execution of a test plan.

Syntax: optionset: filename


Example: optionset: scripts\general\ie4_hr11frame.opt
Back to Top
Q5. Can I pass global variables from SilkOrganizer to SilkTest ?

Yes, you can just reference them directly. For example, if you have a list of
string defined in the test frame, you can pass the variable from SilkOrganizer
as testdata or directly in the testcase statement.

Back to Top
Q6. Is the Extension Kit difficult to use ?

No, if you have the cooperation of the developer (s). If they understand the
value of adding functionality for you and if you're perfectly clear about what
you need, you will have very quick success at implementing the EK. This
assumes that the technology for them to retrieve the information you want
exists within their application. Sometimes with 3rd party controls, there is no
exposed API which provides what you need. Unfortunately, sometimes you
will need to verify some custom objects manually (visually).

Back to Top
Q7. Can I call Silk Scripts from an external shell program. ?

Yes. One way is to just call Silk and pass the name of the script using the
command line arguments. The complete list of arguments is shown below.

Command Line
Options
Syntax: optionset: filename
-m Machine Name
-r Script / Testplan / or Suite Name
-q Quit SilkTest after the script or plan completes execution.
-query Testplan query to run
-p Post error count to calling program
-resexport Output results files to rex files
partner -m
Example: This command would execute the query
LabMachine13 -q
FunctionalTests defined in the testplan InsertNewData,pln
-query
on the machine LabMachine13 and exit SilkTest after the
FunctionalTests -r
testplan completes.
InsertNewData.pln

Back to Top
Q8. What's the difference between SilkTest and QA Partner ?
Originally there was only one product, QA Partner. In 1996, Silk (later renamed
SilkTest), was introduced as the Web Testing tool. It was actually the same
executable as QA Partner, but with browser capabilities turned on. This turned
out to be confusing for most customers. If you bought Silk, you could just turn
off the browser feature and then you'd have QA Partner. However, if you
bought QA Partner, you wouldn't have the ability to test browsers. Starting
with SilkTest 5.0, there is only one product again.

Back to Top
Q9. What is Immediate If?

Immediate If is a 4-test operator which is little known. It allows you to do an if-


then-else on a single line. The syntax is as follows:

boolean ? ReturnValueIfTrue : ReturnValueIfFalse

BOOLEAN bFirstTime = FALSE

STRING sGreeting = bFirstTime ? "Welcome" : "Welcome back"

This

Back to Top
Q10. When do you need to use the "this" keyword and when don't
you?

The "this" keyword is used in window class methods to refer to the instance
variable which is calling the method at runtime. The "this" keyword is only
required when you want to access a data member which is uniquely defined in
the instance. Otherwise its use is optional.
winclass DialogBox : DialogBox
Close ()
this.wCloseButton.Click ()
NewMethod ()
if (Exists ())
// Perform some steps

window DialogBox Test


tag "Test"
Example:
parent MyApplication

window wCloseButton = Exit

PushButton Exit
tag "Exit"

main ()
Test.Close ()
In the close method above, the "this" keyword is required because
the method needs to reference a data member which is declared in
Notes: the instance "Test". In the NewMethod above, this.Exists () is not
required, because it is referencing a method which is defined at the
class level.
File: Download this file
Back to Top
Q11. Should I create a function or a method?

If the action you are automating is:

closely related to a specific window, create a method of that specific window.

closely related to a class of objects, create a method of that window class.

more of a utility, not related to a window or class of windows, create a


function.

Back to Top
Q12. What does the recording statement do?

The recording statement set the following Agent Verification options to FALSE

o OPT_REQUIRE_ACTIVE
o OPT_VERIFY_ACTIVE
o OPT_VERIFY_CLOSED
o OPT_VERIFY_EXPOSED

This can be useful if you specifically want to turn these verifications off for a
specific block of code, but usually it is better to remove the recording
statement after you record the statements you need (run with these options set
to TRUE)
Q13. When and why is the Sleep () statement needed?
Sometimes Silk can't tell when an application is busy. When this happens, Silk
tries to execute the next step which gets thrown away by the application or
causes an error which is usually very difficult to reproduce either manually or
under debug mode. When this happens, a well-placed Sleep (2) or Sleep (5)
can often solve this annoying problem. A few extra sleep statements to make
sure that the application is ready to move forward may be worth the small
difference in the time it takes to execute your scripts.

Вам также может понравиться