Rational RobotJ Field Training - PowerPoint PPT Presentation

Loading...

PPT – Rational RobotJ Field Training PowerPoint presentation | free to download - id: a80ad-MzlmY



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Rational RobotJ Field Training

Description:

... that are printable and are also visible. (A space is printable, but not visible, ... print:] Printable characters (characters that are not control characters. ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 53
Provided by: Kriste137
Learn more at: http://download.boulder.ibm.com
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Rational RobotJ Field Training


1
Rational RobotJ Field Training
  • Advanced Topics

2
Agenda
  • Regular Expressions
  • Debugging
  • Adding Libraries and Classes
  • Data Driven Testing
  • Modifying Options for Script Execution
  • Querying Values of Object Properties
  • Handling Ambiguous Recognition
  • Handling Unexpected Active Windows
  • Adding Manual and Dynamic VPs

3
Regular Expression
4
Regular Expressions
  • Regular Expressions are often used for pattern
    matching or text parsing (remember VU language
    match function).
  • RobotJ uses a class RegEx which is implemented
    using org.apache.regexp.
  • Regular Expressions can be used within a script
  • Regex r new Regex("ab")
  • boolean matched r.matches("aaaab")
  • Regular Expressions can be used to match
    attributes of VP, Recognition.

Right-Click
5
Regular Expressions
  • Characters
  • unicodeChar Matches any identical unicode
    character
  • \ Used to quote a meta-character (like '')
  • \\ Matches a single '\' character
  • \0nnn Matches a given octal character
  • \xhh Matches a given 8-bit hexadecimal
    character
  • \\uhhhh Matches a given 16-bit hexadecimal
    character
  • \t Matches an ASCII tab character
  • \n Matches an ASCII newline character
  • \r Matches an ASCII return character
  • \f Matches an ASCII form feed character
  • Character classes
  • abc Simple character class
  • a-zA-Z Character class with ranges
  • abc Negated character class

6
Regular Expressions
  • Predefined Classes
  • . Matches any character other than newline
  • \w Matches a "word" character (alphanumeric
    plus "_")
  • \W Matches a non-word character
  • \s Matches a whitespace character
  • \S Matches a non-whitespace character
  • \d Matches a digit character
  • \D Matches a non-digit character
  • Boundary Matchers
  • Matches only at the beginning of a line
  • Matches only at the end of a line
  • \b Matches only at a word boundary
  • \B Matches only at a non-word boundary

7
Regular Expressions
  • Greedy Closures (match as many elements as
    possible)
  • A Matches A 0 or more times (greedy)
  • A Matches A 1 or more times (greedy)
  • A? Matches A 1 or 0 times (greedy)
  • An Matches A exactly n times (greedy)
  • An, Matches A at least n times (greedy)
  • An,m Matches A at least n but not more than m
    times (greedy)
  • Reluctant Closures (match as few elements as
    possible)
  • A? Matches A 0 or more times (reluctant)
  • A? Matches A 1 or more times (reluctant)
  • A?? Matches A 0 or 1 times (reluctant)

8
Regular Expressions
  • Logical Operators
  • AB Matches A followed by B
  • AB Matches either A or B
  • (A) Used for subexpression grouping
  • Backreferences
  • \1 Backreference to 1st parenthesized
    subexpression
  • ... (\2,\3,\4,\5,\6,\7,\8)
  • \9 Backreference to 9th parenthesized
    subexpression

9
Regular Expressions
  • Standard POSIX Character Classes
  • alnum Alphanumeric characters.
  • alpha Alphabetic characters.
  • blank Space and tab characters.
  • cntrl Control characters.
  • digit Numeric characters.
  • graph Characters that are printable and are
    also visible.
  • (A space is printable, but not visible, while an
    a' is both.)
  • lower Lower-case alphabetic characters.
  • print Printable characters
  • (characters that are not control characters.)
  • punct Punctuation characters
  • (characters that are not letter, digits, control
    characters, or space characters).
  • space Space characters
  • (such as space, tab, and formfeed, to name a
    few).
  • upper Upper-case alphabetic characters.
  • xdigit Characters that are hexadecimal
    digits.

10
Regular Expressions - Examples
  • The simplest regular expression is a sequence of
    characters and matches any string that contains
    the sequence.
  • def matches abcdefg
  • Certain characters are treated specially by
    Regex.
  • The period (.) matches any single character.a.c
    matches axcd
  • The asterisk or star () matches any repeating
    sequence (0 or more) of the previous pattern.ad
    matches aaaaadad matches d
  • The plus () matches any repeating sequence (1 or
    more) of the previous pattern.ad matches
    aaaaadad matches not d

11
Regular Expressions - Examples
  • The question mark (?) matches 0 or 1 of the
    previous pattern.ab?c matches acab?c matches
    abc
  • Parentheses can be used to group
    patterns.a(bc)d matches abcbcbcbcd
  • You can indicate multiple choices using the
    vertical bar ().redgreenblue matches
    redx(redgreenblue)x matches xredblueredx
  • You can indicate a set of characters using square
    brackets ().xabx matches xaxxabx matches
    xbx0-9 matches 12378

12
Debugging
13
Debugging
  • Integrated debugger supports
  • Debugging of RobotJ scripts
  • Debugging of Local Java Application
  • Debugging of Remote Java Application
  • To playback script until a certain point use
    stop()

14
Debugging Perspective
Debug controls
Debug views

Breakpoint
Outline View for navigation of source
15
Basic Debugger Controls
  • Accessed via
  • Debug menu
  • Debug perspective control panel
  • The debugger gives numerous controls to the
    developer
  • Pause
  • Resume
  • Step Into allows you to load any referenced
    code
  • Step Over skips referenced code
  • e.g. skipping over println() calls in the code

16
Working with breakpoints
  • Breakpoints are set directly in the source via
    the context menu
  • Shown along the left edge
  • Breakpoint view lists all breakpoints that exist
  • Manipulation functions (e.g. remove, disable,
    etc.) available via the context menu

17
Inspecting variables
  • The stack contents
  • Displayed automatically in the variables view as
    you step through code
  • To inspect variables at a given point
  • Highlight in source editor in debug perspective
  • Choose inspect from the context menu

18
Evaluating expressions and code snippets
  • The display view allows you to evaluate
    expressions interactively
  • Useful for experimenting and testing ideas, ,
    etc.
  • e.g. results of some calculation that is not in
    the source
  • Similar to an interpreter
  • To evaluate an expression
  • Type it in the display view
  • Highlight and choose display from the context menu

19
Adding Libraries and Classes
20
Adding libraries to the build path
  • To add external JARS, folders, etc. to the build
    path
  • Open Project Properties
  • Select Libraries tab
  • Navigate and add appropriate folders, libraries,
    etc.

21
Bringing in Java code into the project
  • To bring in existing Java code to a project
  • Use FilegtImport
  • Select File system option for importing source
    files
  • Select Zip File option for importing Jar files
  • Navigate to folder or file(s)
  • Select individual elements
  • Finish

NOTE Import is a copy operation. Copy is
located in the project folder. After the import,
two versions of the imported resources exist in
the environment.
22
Data Driven Testing
23
Data Driven Testing
  • Data-driven tests play back user input from a
    file rather than using the input taken
    interactively during recording
  • Possible Source of Data
  • Flat files
  • Database files
  • Rational TSS datapools- incl. all .jar-files
  • Java knowledge is required
  • (no this is not the PM of RobotJ!)

24
Data Driven Testing
  • Record a test as usual, which generates a RobotJ
    script.
  • Add the Java code necessary to load the data file
    before the startApp command.
  • Create an indexed loop around the test that
    reads the data source record by record.
  • Replace the commands in the RobotJ script where
    the data was entered interactively with commands
    that read from the data source.
  • Play back the RobotJ script to ensure that the
    data is read correctly.

25
Data Driven Testing - Example
  • JavaClassicsA - UC
  • The user selects a CD and clicks on the Place
    Order button.
  • The user enters a name and password and clicks on
    the OK button
  • The user places an order specifying quantity,
    credit card number, and credit card expiration
    date and clicks on the Place Order button.
  • The user click on the OK button of the
    confirmation dialog.
  • The user selects the View Existing Order Status
    menu option.
  • The user enters name and password again to view
    the status of the order and clicks on the OK
    button.
  • The user selects the order and clicks on the
    Cancel Selected Order button. Clicks on Close
    button
  • The user closes the application.

26
Data Driven Testing
  • Script Overview
  • New import directives
  • Restructured testMain

Container for data records
File, DB or DP
New function for main test case
27
Data Driven Testing - Example
  • Before vs. After

Recorded Values
Replaced Values
28
Data Driven Testing - Example
  • Loading Test Data - File

See Advanced Topics in RobotJ Help!
Java programming knowledge needed!
29
Modifying Options for Script Execution
30
Modifying Options for Script Execution
  • Options specified with UI can be changed
  • Method calls to change options during playback
  • Object x getOption(IOptionName.option)
  • setOption(IOptionName.option,value)
  • resetOption(IOptionName.DELAY_BEFORE_KEY_DOWN)
  • Values can be found at
  • RobotJ API Reference com.rational.test.ft.script.
    IOptionName
  • Only valid during playback

31
Querying Values of Object Properties
32
Querying Values of Object Properties
  • Accessing object property UC
  • You may want to compare previous versions of a
    value to the current value and to do so would
    require a calculation .
  • Sometimes objects have methods that return other
    objects and you may need to test on the value of
    a property of the returned object.
  • You also may want to branch in your RobotJ script
    based on the current value of a property.
  • Methods GET/SET
  • Object getProperty(String propertyName)
  • void setProperty(String , ...)

33
Querying Values of Object Properties
  • Example

34
Handling Ambiguous Recognition
35
Handling Ambiguous Recognition
  • Ambiguous recognition can happen when more than
    one instances a Java application is used/started
    during recording.

36
Handling Ambiguous Recognition
  • Using ProcessTestObjects to identify the
    application
  • Manual coding required!

Ambiguous Recognition
Non Ambiguous Recognition
37
Handling Unexpected Active Windows
38
Handling Unexpected Active windows
  • RobotJ has no standard mechanism (vs. Robot)!
  • There is no out-of-the-box approach!
  • Code can be added to test script
  • Pros Easy to do
  • Cons Has to be added wherever it is need!
  • Code can be added to a custom helper class(the
    dark side of RobotJ)
  • Pros More general
  • Cons Not trivial!

again NO, this is not the PM of RobotJ
New helper super class is NOTgenerated!! User
has to create the class!!
39
Handling Unexpected Active windows
  • Add code to script Example
  • Some browsers show a dialog when switching
    between secure/non-secure pages
  • Some browsers dont
  • Or will not do aftermore than 5 seconds

40
Handling Unexpected Active windows
  • Create new helper class before next recording
  • Recorder preferences
  • Every script recorded afterthis change will use
    the newhelper super class!
  • Change script template
  • all scripts in DataStore will be usingthe new
    helper super class!

New helper super class is NOTgenerated!! User
has to create the class!!
41
Super Helper Class
Added custom helper
Default
RationalTestScript - onObjectNotFound
CustomHelper - onObjectNotFound
ATestScriptHelper
ATestScriptHelper
ATestScript
ATestScript
After recording you will see the script
42
Handling Unexpected Active windows
  • Override onObjectNotFound Method in new super
    helper class
  • Sample codewill be provided!

43
Adding Manual and Dynamic VPs
44
Adding Manual VPs 3 Different Kinds
  • Static (Recorded) - Verification points created
    at record time that are ready to play back at the
    appropriate time during execution of test script.
  • Manual - Verification points in which the data
    supplied by the script developer. The
    verification point interface only compares and
    logs the result with persistence as appropriate.
  • Dynamic - Verification points that are created at
    playback time, the first time that the script is
    run. These verification points act like recorded
    scripts after the baseline for the verification
    point is established.

45
Adding Manual VPs
  • UC1
  • Verify base lined data during execution. This can
    also be non GUI-based data like e.g. data base
    record field, any data available in application
    or a result of calculation/transformation.
  • UC2
  • Compare dynamic data during execution. This can
    also be non GUI-based data like e.g. data base
    record field, any data available in application
    or a result of calculation/transformation.
  • Important Information
  • All data types or objects that should be used
    have to be supported VALUE types! Extensibility
    is possible but not within the first release!

46
Adding Manual VPs
  • Manual VPs
  • IFtVerificationPoint vpManual (java.lang.String
    vpName, java.lang.Object actual)
  • IFtVerificationPoint vpManual (java.lang.String
    vpName, java.lang.Object expected,
    java.lang.Object actual)
  • vpName must be unique in a script!
  • Before performTest() is executed the first time a
    baseline is created.

47
Adding Manual VPs
  • Before execution
  • Log viewer (HTML)
  • After execution
  • ! no manual2!

New!
48
Adding Dynamic VPs
  • UC Insert verification point into script.
  • Specify line of script by adding dynamic VP,
    without specifying the object. At runtime the
    object will be select with the object finder
    dialog.
  • Specify line and object of script by adding a
    dynamic VP, with specifying the object. At
    runtime the object will already be selected but
    user has to finish verification point dialogs.
  • After first run, those VPs behave like static
    VPs.

49
Adding Dynamic VPs
  • Dynamic VPs
  • IFtVerificationPoint vpDynamic (java.lang.String
    vpName)
  •  
  • IFtVerificationPoint vpDynamic (java.lang.String
    vpName, TestObject objectUnderTest)
  • vpName must be unique in a script!

1
2
50
Adding Dynamic VPs
1
  • First execution of statement starts VP dialog
  • Select objectto verify

1
51
Adding Dynamic VPs
2
  • First execution of statement starts VP dialog,
    with object already selected
  • Object alreadyselected!

2
52
Adding Dynamic VPs
  • Before execution
  • Log Viewer (HTML)
  • After execution

New!
53
Questions
About PowerShow.com