jIETest
A Perl module for automating Internet Explorer.
Description
jIETest runs the Internet Explorer COM object model. From there you
can manipulate IE to click, navigate, tec.
The original version of jIETest came from samie
http://samie.sourceforge.net
I took it and:
- refactored extensively
- rewrote some parts
- added embedded documentation
- added a lot of tracing/debug code
- added result log
- removed procedural style interface and replaced it with object-oriented style
- implemented a naming convention for the functions
- added file/line information to the result log
- wrote self tests which translates into 2300 or so asserts.
These can be invoked randomly (see testjietest.pl), it takes about
10 minutes to run 1000 tests.
Check here for a Ruby version:
http://rubyforge.org/projects/wtr
and
http://pamie.sourceforge.net
for a Python version.
Author
John Arrizza (+ the samie authors + the watir authors)
Configuration
These are the versions I use to test as reported by Module::Versions::Report
| ActiveState Perl | v5.8.8 build 822 (or later)
|
| AutoLoader | v5.63
|
| Exporter | v5.60;
|
| Thread::Semaphore | v2.06;
|
| threads | v1.72
|
| threads::shared | v1.12
|
| Time::HiRes | v1.9707
|
| Tk | v804.027;
|
| Tk::ItemStyle | v4.004;
|
| Tk::LabFrame | v4.010;
|
| Tk::Tree | v4.005;
|
| Win32::Capture | v1.1;
|
| Win32::GUI | v1.06
|
| Win32::GUI::DIBitmap | v0.17;
|
| Win32::GuiTest | v1.54;
|
| Win32::Mutex | v1.02;
|
| Win32::OLE | v0.1707;
|
Installation
Using activestate Perl v5.88 build 822 or later, the following additional actions are required:
- ppm rep add bribes http://www.bribes.org/perl/ppm
- ppm install Win32-GUI (v1.06 or later)
- ppm install Win32-GuiTest
- ppm install Win32-Capture
- ppm install Tk (for self-tests in testjietest.pl)
Known Bugs
- Frames may or may not be working. It is untested.
- Message boxes (javascript alert) have different titles in IE8. Can only handle IE8 message boxes.
- MSWord pages cause certain functions to fail with OLE errors: VerifyTitle, PrintObjectInfo. There may be others.
Missing Features
- add timeouts on page loads
- Form::Click click an element within a given form
- unordered lists
- ordered lists
- frames
- handle special characters in text
- map
- input type=file
- input type=hidden
- input type="image.png"
Session Routines
Creates an instance of jIETest object.
| Parameters
|
| none |
|
| Return Value: a jIETest object
|
Sets the Debug verbosity
| Parameters
|
| mode | 'all' or ''; default ''
|
| Return Value: none
|
Starts an Internet Explorer session. This must be the first command to be issued.
If it fails, the script is exited.
| Parameters
|
| maximize | 1 (default) display window maximize, 0 display
|
| Return Value: none
|
Quits the current session.
If this command is not used, the last IE session remains up and you will
have to kill it manually.
| Parameters
|
| none |
|
| Return Value: none
|
Gets IE Compatibility mode
| Parameters
|
| none |
|
| Return Value: 5, 6, 7 or 8
|
Get a screen capture of the client area and save it to a file
| Parameters
|
| filename | the file to save the screen to
|
| Return Value: none
|
Navigation Routines
Goes to the given url.
| Parameters
|
| url | the url to navigate to
|
| Return Value: none
|
Navigates back one page (if there is one). This is equivalent to
pressing the Back button on the browser.
| Parameters
|
| none |
|
| Return Value: none
|
Refreshes the current page.
It is equivalent to pressing the Refresh button on the browser.
| Parameters
|
| none |
|
| Return Value: none
|
Popup Routines
Get next popup session object.
| Parameters
|
| none |
|
| Return Value: jIETest object
|
Expect a Security popup during the next operation.
If one occurs, the 'OK' button will be pressed and the popup cleared.
Only one popup will be cleared at a time.
| Parameters
|
| enable | 1 to clear the popup (default), 0 to ignore the popup
|
| Return Value: none
|
Expect a Login popup during the next operation. If one occurs, the userid and password
fields will be filled in and the 'OK' button will be pressed.
Only one popup will be filled at a time.
call with no parameters to disable the check for the login popup
| Parameters
|
| userid | the user id to use
|
| password | the password to use
|
| title | a portion of the title text of the message box. Default: 'Connect to'
|
| Return Value: none
|
Reporting Routines
Print a message to the result file. It is also printed to the trace file.
| Parameters
|
| message | the message to write to the Result file
|
| type | 'append' (default) to append to the end of the Result file; 'write' to truncate first; 'nolast' used only by Self-test
|
| Return Value: none
|
Truncates the result file.
| Parameters
|
| message | the message to write to the Result file
|
| type | 'append' (default) to append to the end of the Result file; 'write' to truncate first; 'nolast' used only by Self-test
|
| Return Value: none
|
Print a formatted test result.
| Parameters
|
| testinfo | identifies the test
|
| result | PASS, FAIL, or WARNING
|
| msg | additional information
|
| Return Value: none
|
Checkbox Routines
Get a node representing a CheckBox
| Parameters
|
| value | the id, name or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/innertext, default: 0
|
| Return Value: node or undef
|
Does the checkbox Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the checkbox
| Parameters
|
| none |
|
| Return Value: none
|
Set the state of the checkbox
| Parameters
|
| state | 1 for on, 0 for off
|
| Return Value: none
|
Does the current state of the checkbox match the given state?
| Parameters
|
| expectedstate | 1 for on, 0 for off
|
| Return Value: 1 if it matches, else 0
|
Verify the current state matches the given state.
| Parameters
|
| state | the expected state of the CheckBox
|
| Return Value: 1 if found, else 0
|
Label Routines
Get a node representing a Label
| Parameters
|
| value | the id, name or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/innertext
|
| Return Value: node or undef
|
Does the label Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the label
| Parameters
|
| none |
|
| Return Value: none
|
Link Routines
Get a node representing a Link
| Parameters
|
| value | the id, name or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/innertext
|
| Return Value: node or undef
|
Does the link Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the link
| Parameters
|
| wdc | wait (default) or nowait
|
| Return Value: none
|
Verify the inntertext of the link matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
Does the inntertext of the link match the given text?
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if it matches, else 0
|
DIV Routines
Get a node representing a DIV
| Parameters
|
| value | the id, name or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/innertext
|
| Return Value: node or undef
|
Does the div Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the div
| Parameters
|
| none |
|
| Return Value: none
|
Verify the innertext of the div matches the given text
| Parameters
|
| epected | the expected text
|
| Return Value: 1 if found, else 0
|
Does the innertext of the div match the given text?
| Parameters
|
| epected | the expected text
|
| Return Value: 1 if it matches, else 0
|
Button Routines
Get a node representing a Button
| Parameters
|
| value | the id, name or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/innertext
|
| Return Value: node or undef
|
Does the button Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the button
| Parameters
|
| none |
|
| Return Value: none
|
Verify the inntertext of the button matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
Does the inntertext of the button match the given text?
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if it matches, else 0
|
Submit Button Routines
Get a node representing a submit Button
| Parameters
|
| value | the id, name or value to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/value
|
| Return Value: node or undef
|
Does the submitbutton Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the submitbutton
| Parameters
|
| wdc | 'wait' (default): wait for DocumentComplete message, 'nowait': continue after clicking
|
| Return Value: none
|
Radio Button Routines
Get a node representing a Radio Button
| Parameters
|
| value | the id, name or value to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/value
|
| Return Value: node or undef
|
Does the radiobutton Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the radiobutton
| Parameters
|
| none |
|
| Return Value: none
|
Verify the state of the radiobutton matches the given state
| Parameters
|
| expected | the expected state
|
| Return Value: 1 if found, else 0
|
Does the state of the radiobutton match the given state?
| Parameters
|
| expected | the expected state
|
| Return Value: 1 if it matches, else 0
|
Image Routines
Get a node representing an Image
| Parameters
|
| value | the id, name, alt or src to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/alt/src
|
| Return Value: node or undef
|
Does the image Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the image
| Parameters
|
| none |
|
| Return Value: none
|
Verify the ALT Text of the image matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
EditBox Routines
Get a node representing an Edit Box
| Parameters
|
| value | the id, name or value to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/value
|
| Return Value: node or undef
|
Does the editbox Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the editbox
| Parameters
|
| none |
|
| Return Value: none
|
Set the text of the editbox
| Parameters
|
| text | the text to set
|
| Return Value: none
|
Verify the inntertext of the editbox matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
Does the inntertext of the editbox match the given text?
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if it matches, else 0
|
TextArea Routines
Get a node representing an TextArea
| Parameters
|
| value | the id, name, value or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name/innertext
|
| Return Value: node or undef
|
Does the textarea Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the textarea
| Parameters
|
| none |
|
| Return Value: none
|
Set the text of the textarea
| Parameters
|
| text | the text to set
|
| Return Value: none
|
Verify the inntertext of the textarea matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
Does the inntertext of the textarea match the given text?
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if it matches, else 0
|
Password Box Routines
Get a node representing a Password Box
| Parameters
|
| value | the id or name to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
| Return Value: node or undef
|
Does the passwordbox Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the passwordbox
| Parameters
|
| none |
|
| Return Value: none
|
Set the passwordbox to the given text
| Parameters
|
| text | the new value
|
| Return Value: none
|
Verify the inntertext of the passwordbox matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
Does the inntertext of the passwordbox match the given text?
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if it matches, else 0
|
ListBox Routines
Get a node representing a ListBox
| Parameters
|
| value | the id or name to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
| Return Value: node or undef
|
Does the listbox Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the listbox
| Parameters
|
| none |
|
| Return Value: none
|
Set state of the listbox to the given option name, id or value
| Parameters
|
| option | the option to set
|
| Return Value: none
|
Set state of the listbox to the given option text
| Parameters
|
| option | the option to set
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| Return Value: none
|
Check if the given option exists
| Parameters
|
| option | the option to search for.
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| Return Value: 1 if it exists, else 0
|
Does the current selection of the listbox match the given option?
| Parameters
|
| expected | the expected option
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| Return Value: 1 if it matches, else 0
|
Does the current selection of the listbox match the given option's text?
| Parameters
|
| expected | the expected option's text
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| Return Value: 1 if it matches, else 0
|
Verify the current selection of the listbox matches the given option
| Parameters
|
| expected | the expected option
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| Return Value: 1 if found, else 0
|
Form Routines
Get a node representing a Form
| Parameters
|
| value | the id or name to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
| Return Value: node or undef
|
Does the form Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the form
| Parameters
|
| none |
|
| Return Value: none
|
Get an element from the form
| Parameters
|
| value | the id, name or innertext to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
Does the formelement Exist?
| Parameters
|
| none |
|
| Return Value: none
|
Click the formelement
| Parameters
|
| none |
|
| Return Value: none
|
Table Routines
Gets a Table node
| Parameters
|
| value | the id or name to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
| Return Value: jIETestNode object holding the Table
|
Does the table Exist?
| Parameters
|
| none |
|
| Return Value: none
|
Click the table
| Parameters
|
| none |
|
| Return Value: none
|
Get the given cell from the table at the given row and column
| Parameters
|
| row | row index (0-based)
|
| col | column index (0-based)
|
| Return Value: a node representing a cell or undef
|
Get the number of rows in the table
| Parameters
|
| none |
|
| Return Value: the number of rows
|
Verify the number of rows in the table
| Parameters
|
| expected | the expected number of rows
|
| Return Value: 1 if found, else 0
|
Get the given row from the table
| Parameters
|
| row | the row to get
|
| Return Value: a node representing the row or undef
|
Table Row and Column Routines
Does the tablerow Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the tablerow
| Parameters
|
| none |
|
| Return Value: none
|
Get the number of columns in the tablerow
| Parameters
|
| none |
|
| Return Value: the number of columns
|
Verify the number of columns in the tablerow matches the given number
| Parameters
|
| expected | the expected number of columns
|
| Return Value: 1 if found, else 0
|
Table Cell Routines
Does the tablecell Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the tablecell
| Parameters
|
| none |
|
| Return Value: none
|
Get the value of the tablecell
| Parameters
|
| none |
|
| Return Value: the innertext value
|
Verify the inntertext of the tablecell matches the given text
| Parameters
|
| expected | the expected text
|
| Return Value: 1 if found, else 0
|
Generic Page Element Routines
Get a node representing a page element
| Parameters
|
| tagname | the tag name to search for, e.g. 'BUTTON'
|
| value | the id, name, innertext or value to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
| Return Value: node or undef
|
Does the pageelement Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the pageelement
| Parameters
|
| none |
|
| Return Value: none
|
Get a node representing a page element
| Parameters
|
| tagname | the tag name to search for, e.g. 'INPUT'
|
| tagtype | the type of tag name to search for, e.g. 'radio'
|
| value | the id, name, innertext or value to search for (in that order).
Use qr/pattern/ to search for a pattern, or pass in a scalar to match exactly.
|
| count | number of elements to skip with the same id/name
|
| Return Value: node or undef
|
Does the pageelementwithtype Exist?
| Parameters
|
| none |
|
| Return Value: 1 if exists, else 0
|
Click the pageelementwithtype
| Parameters
|
| none |
|
| Return Value: none
|
Text Routines
Does the current page have the given text somewhere on it (innerText fields only)?
| Parameters
|
| text | the expected text
|
| count | number of elements to skip
|
| Return Value: 1 if text is found, 0 if not
|
Verify the given text is somewhere on the current page (innerText fields only)
| Parameters
|
| text | the expected text
|
| count | number of elements to skip
|
| Return Value: 1 if found, else 0
|
Verify the given text is not on the current page (innerText fields only)
| Parameters
|
| text | the expected text
|
| Return Value: 1 if found, else 0
|
Does the current page have all the given text strings somewhere on it (innerText fields only)?
| Parameters
|
| list | the expected list of text strings
|
| Return Value: 1 if text is found, else 0
|
Verify that all the given text strings are somewhere on the current page (innerText fields only)
| Parameters
|
| list | the expected list of text strings
|
| Return Value: 1 if found, else 0
|
MessageBox Routines
Expect a message box to pop up during the next action.
| Parameters
|
| timeout | how long in seconds to wait for the timeout; use 0 to wait forever; default is 0
|
| Return Value: none
|
Verify a message box contains the given text.
It also clears the cache of message box text lines
| Parameters
|
| text | the expected text to verify
|
| Return Value: 1 if found, else 0
|
Status Bar Routines
Verify that the Status Bar either currently contains or has contained the given text
| Parameters
|
| text | the expected text in the Status Bar
|
| Return Value: 1 if found, else 0
|
URL Routines
Is the current page at the given URL?
| Parameters
|
| url | the expected URL
|
| Return Value: 1 if current page is on given URL, 0 otherwise
|
Verify if the current page has the given URL.
| Parameters
|
| url | the expected URL
|
| Return Value: 1 if found, else 0
|
Page Title Routines
Does the current page have the given Title?
| Parameters
|
| text | the expected title
|
| Return Value: 1 if title was found, 0 otherwise
|
Verify if the current page has the given Title.
| Parameters
|
| text | the expected title
|
| Return Value: 1 if found, else 0
|
Misc. Routines
Saves the current page's OuterText into the given filename.
The OuterText fields of the IE DOM contain a text-only
representation of that field, so the content of the file will
be the concatenation of all the OuterText fields of the current page.
There will not be any HTML in the OuterText.
If the file already exist, it will be overwritten.
| Parameters
|
| filename | the name of the file to write to
|
| Return Value: none
|
Print object information for all elements on the current page.
The information printed are those required by most of the Click or Set functions.
| Parameters
|
| none |
|
| Return Value: none
|
Print all object information for all elements on the current page
| Parameters
|
| none |
|
| Return Value: none
|