Search This Blog

Wednesday, August 4, 2010

How to send a key command to a Web object in QTP

Some Web objects will perform actions when certain key commands, such as ALT+RETURN, are entered. These Web objects do not have a type method associated with them that can be used to replay these keys. How can the key combination be replayed?

________________________________________
Solution: Use the Windows Scripting SendKeys method
1. Create a WScript.Shell object.
2. Activate the browser in which you want to execute the keys.
3. Use the SendKeys method to type the key combination.
Example:
‘ This code executes the CTRL+F key combination (search) on a browser.
Set WshShell = CreateObject(”WScript.Shell”)
WshShell.AppActivate “Put the label of the browser” ‘ Activate the browser window
wait(3)
WshShell.SendKeys “^f” ‘ The caret (^) represents the CTRL key.
wait(2)
object.SendKeys(string)
object A WshShell object.
string The string value indicating the keystroke(s) you want to send.
The SendKeys method will send keystroke(s) to the active window. To send a single character (for example, x), use “x” as the string argument. To send multiple characters (for example, abc), use “abc” as the string argument. You can also send special characters such as SHIFT, CTRL, and ALT, which are represented by the plus sign (+), the caret (^), and the percent sign (%), respectively.
For more information on the SendKeys method and other special keys, such as the backspace or a function key, please refer to the MSDN SendKeys Method page.
====================================================================================================
‘ Name: KeyboardShortCut

‘ Input:
‘ ByRef Key As Variant - The keyboard key to be typed.
‘ ByRef Pane As Variant - The window/pane to type in.
‘ Purpose: To type keyboard input onto the open window.
‘====================================================================================================
Function KeyboardShortCut (Key)
dim obj
Set obj = Window(”Window Name” ).WinObject(”Object”)
obj.type Key
Environment(”LastResult”) = “Success”
End Function
Solution2: Pressing Function keys should be recorded automatically
Directly recording on the application and pressing the Function Keys (F1, F2, etc.) should generate code for replay.
Example:
‘Here is an example recorded against Notepad:
Window(”Notepad”).Activate
Window(”Notepad”).WinEditor(”Edit”).Type micF5
If the above does not work, then you can use DeviceReplay to simulate pressing keyboard keys.
Example:
‘Here is an example that does the same thing above, but used DeviceReplay.
Set obj = CreateObject(”Mercury.DeviceReplay”)
Window(”Notepad”).Activate
obj.PressKey 63
Note:
The PressKey method uses the appropriate ASCII or IBM Scan Code value for the key. “63″ is the IBM Scan Code value for F5.

Sample Selenium Test Suite

TestSuite.html
Test suite for the whole application
Access main page
Login to application
Change address
Logout from application











Open fire fox not selenium IDE and paste this link in the address bar

chrome://selenium-ide/content/selenium/TestRunner.html?baseURL=http://localhost&test=file:///dir/testsuite.html&auto=true



replace http://localhost with the baseURL of your server






Running Test Suite from command line
If you want to run a number of tests from the command line - for example, as an acceptance test step, or as a part of the checkin, you have a couple of options.
1) Selenium RC provides convenient command-line support for running HTML Selenese tests from the command-line or with Ant: http://www.openqa.org/selenium-rc/selenese.html
2) Create a batch file that launches Firefox pointed to the suite. For example, on Windows, my batch file looks like:
"C:\Program Files\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content/selenium/TestRunner.html?test=file:///C:/tests/AllTests.html&auto=true&baseURL=http://mysite.com " -height 900 -width 900

Selenium Commands - Part 9

U

uncheck(locator)
Arguments:
• locator - an element locator
Uncheck a toggle-button (checkbox/radio)


uncheckAndWait(locator)
Generated from uncheck(locator)
Arguments:
• locator - an element locator
Uncheck a toggle-button (checkbox/radio)

Selenium Commands - Part 8

T

type(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Sets the value of an input field, as though you typed it in.
Can also be used to set the value of combo boxes, check boxes, etc. In these cases, value should be the value of the option selected, not the visible text.


typeAndWait(locator, value)
Generated from type(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Sets the value of an input field, as though you typed it in.
Can also be used to set the value of combo boxes, check boxes, etc. In these cases, value should be the value of the option selected, not the visible text.


typeKeys(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Simulates keystroke events on the specified element, as though you typed the value key-by-key.
This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string; this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
Unlike the simple "type" command, which forces the specified value into the page directly, this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.


typeKeysAndWait(locator, value)
Generated from typeKeys(locator, value)
Arguments:
• locator - an element locator
• value - the value to type
Simulates keystroke events on the specified element, as though you typed the value key-by-key.
This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string; this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
Unlike the simple "type" command, which forces the specified value into the page directly, this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.

Selenium Commands - Part 7

S

select(selectLocator, optionLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
• optionLocator - an option locator (a label by default)
Select an option from a drop-down using an option locator.
Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option, or for asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.
• label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
o label=regexp:^[Oo]ther
• value=valuePattern: matches options based on their values.
o value=other
• id=id: matches options based on their ids.
o id=option1
• index=index: matches an option based on its index (offset from zero).
o index=2
If no option locator prefix is provided, the default behaviour is to match on label.


selectAndWait(selectLocator, optionLocator)
Generated from select(selectLocator, optionLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
• optionLocator - an option locator (a label by default)
Select an option from a drop-down using an option locator.
Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option, or for asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.
• label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
o label=regexp:^[Oo]ther
• value=valuePattern: matches options based on their values.
o value=other
• id=id: matches options based on their ids.
o id=option1
• index=index: matches an option based on its index (offset from zero).
o index=2
If no option locator prefix is provided, the default behaviour is to match on label.


selectFrame(locator)
Arguments:
• locator - an element locator identifying a frame or iframe
Selects a frame within the current window. (You may invoke this command multiple times to select nested frames.) To select the parent frame, use "relative=parent" as a locator; to select the top frame, use "relative=top".
You may also use a DOM expression to identify the frame you want directly, like this: dom=frames["main"].frames["subframe"]


selectWindow(windowID)
Arguments:
• windowID - the JavaScript window ID of the window to select
Selects a popup window; once a popup window has been selected, all commands go to that window. To select the main window again, use null as the target.
Selenium has several strategies for finding the window object referred to by the "windowID" parameter.
1.) if windowID is null, then it is assumed the user is referring to the original window instantiated by the browser).
2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed that this variable contains the return value from a call to the JavaScript window.open() method.
3.) Otherwise, selenium looks in a hash it maintains that maps string names to window objects. Each of these string names matches the second parameter "windowName" past to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag) (which selenium intercepts).
If you're having trouble figuring out what is the name of a window that you want to manipulate, look at the selenium log messages which identify the names of windows created via window.open (and therefore intercepted by selenium). You will see messages like the following for each window as it is opened:
debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"
In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example). (This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using an empty (blank) url, like this: openWindow("", "myFunnyWindow").


setContext(context, logLevelThreshold)
Arguments:
• context - the message to be sent to the browser
• logLevelThreshold - one of "debug", "info", "warn", "error", sets the threshold for browser-side logging
Writes a message to the status bar and adds a note to the browser-side log.
If logLevelThreshold is specified, set the threshold for logging to that level (debug, info, warn, error).
(Note that the browser-side logs will not be sent back to the server, and are invisible to the Client Driver.)


setCursorPosition(locator, position)
Arguments:
• locator - an element locator pointing to an input element or textarea
• position - the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field.
Moves the text cursor to the specified position in the given input element or textarea. This method will fail if the specified element isn't an input element or textarea.


setCursorPositionAndWait(locator, position)
Generated from setCursorPosition(locator, position)
Arguments:
• locator - an element locator pointing to an input element or textarea
• position - the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field. You can also set the cursor to -1 to move it to the end of the field.
Moves the text cursor to the specified position in the given input element or textarea. This method will fail if the specified element isn't an input element or textarea.


setMouseSpeed(pixels)
Arguments:
• pixels - the number of pixels between "mousemove" events
Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
Setting this value to 0 means that we'll send a "mousemove" event to every single pixel in between the start location and the end location; that can be very slow, and may cause some browsers to force the JavaScript to timeout.
If the mouse speed is greater than the distance between the two dragged objects, we'll just send one "mousemove" at the start location and then one final one at the end location.


setMouseSpeedAndWait(pixels)
Generated from setMouseSpeed(pixels)
Arguments:
• pixels - the number of pixels between "mousemove" events
Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
Setting this value to 0 means that we'll send a "mousemove" event to every single pixel in between the start location and the end location; that can be very slow, and may cause some browsers to force the JavaScript to timeout.
If the mouse speed is greater than the distance between the two dragged objects, we'll just send one "mousemove" at the start location and then one final one at the end location.


setSpeed(value)
Arguments:
• value - the number of milliseconds to pause after operation
Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e., the delay is 0 milliseconds.


setSpeedAndWait(value)
Generated from setSpeed(value)
Arguments:
• value - the number of milliseconds to pause after operation
Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e., the delay is 0 milliseconds.


setTimeout(timeout)
Arguments:
• timeout - a timeout in milliseconds, after which the action will return with an error
Specifies the amount of time that Selenium will wait for actions to complete.
Actions that require waiting include "open" and the "waitFor*" actions.
The default timeout is 30 seconds.


shiftKeyDown()
Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.


shiftKeyDownAndWait()
Generated from shiftKeyDown()
Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.


shiftKeyUp()
Release the shift key.


shiftKeyUpAndWait()
Generated from shiftKeyUp()
Release the shift key.


storeAlert(variableName)
Generated from getAlert()
Returns:
The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.
NOTE: Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.


storeAlertPresent(variableName)
Generated from isAlertPresent()
Returns:
true if there is an alert
Has an alert occurred?
This function never throws an exception


storeAllButtons(variableName)
Generated from getAllButtons()
Returns:
the IDs of all buttons on the page
Returns the IDs of all buttons on the page.
If a given button has no ID, it will appear as "" in this array.


storeAllFields(variableName)
Generated from getAllFields()
Returns:
the IDs of all field on the page
Returns the IDs of all input fields on the page.
If a given field has no ID, it will appear as "" in this array.


storeAllLinks(variableName)
Generated from getAllLinks()
Returns:
the IDs of all links on the page
Returns the IDs of all links on the page.
If a given link has no ID, it will appear as "" in this array.


storeAllWindowIds(variableName)
Generated from getAllWindowIds()
Returns:
the IDs of all windows that the browser knows about.
Returns the IDs of all windows that the browser knows about.

storeAllWindowNames(variableName)
Generated from getAllWindowNames()
Returns:
the names of all windows that the browser knows about.
Returns the names of all windows that the browser knows about.


storeAllWindowTitles(variableName)
Generated from getAllWindowTitles()
Returns:
the titles of all windows that the browser knows about.
Returns the titles of all windows that the browser knows about.


storeAttribute(attributeLocator, variableName)
Generated from getAttribute(attributeLocator)
Arguments:
• attributeLocator - an element locator followed by an
Returns:
the value of the specified attribute
Gets the value of an element attribute.


storeAttributeFromAllWindows(attributeName, variableName)
Generated from getAttributeFromAllWindows(attributeName)
Arguments:
• attributeName - name of an attribute on the windows
Returns:
the set of values of this attribute from all known windows.
Returns every instance of some attribute from all known windows.


storeBodyText(variableName)
Generated from getBodyText()
Returns:
the entire text of the page
Gets the entire text of the page.


storeChecked(locator, variableName)
Generated from isChecked(locator)
Arguments:
• locator - an element locator pointing to a checkbox or radio button
Returns:
true if the checkbox is checked, false otherwise
Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.


storeConfirmation(variableName)
Generated from getConfirmation()
Returns:
the message of the most recent JavaScript confirmation dialog
Retrieves the message of a JavaScript confirmation dialog generated during the previous action.
By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command. If an confirmation is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.


storeConfirmationPresent(variableName)
Generated from isConfirmationPresent()
Returns:
true if there is a pending confirmation
Has confirm() been called?
This function never throws an exception


storeCookie(variableName)
Generated from getCookie()
Returns:
all cookies of the current page under test
Return all cookies of the current page under test.


storeCursorPosition(locator, variableName)
Generated from getCursorPosition(locator)
Arguments:
• locator - an element locator pointing to an input element or textarea
Returns:
the numerical position of the cursor in the field
Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.


storeEditable(locator, variableName)
Generated from isEditable(locator)
Arguments:
• locator - an element locator
Returns:
true if the input element is editable, false otherwise
Determines whether the specified input element is editable, ie hasn't been disabled. This method will fail if the specified element isn't an input element.


storeElementHeight(locator, variableName)
Generated from getElementHeight(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
height of an element in pixels
Retrieves the height of an element


storeElementIndex(locator, variableName)
Generated from getElementIndex(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
of relative index of the element to its parent (starting from 0)
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.


storeElementPositionLeft(locator, variableName)
Generated from getElementPositionLeft(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the horizontal position of an element


storeElementPositionTop(locator, variableName)
Generated from getElementPositionTop(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the vertical position of an element


storeElementPresent(locator, variableName)
Generated from isElementPresent(locator)
Arguments:
• locator - an element locator
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.


storeElementWidth(locator, variableName)
Generated from getElementWidth(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
width of an element in pixels
Retrieves the width of an element


storeEval(script, variableName)
Generated from getEval(script)
Arguments:
• script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object, and window will refer to the top-level runner test window, not the window of your application.
If you need a reference to the window of your application, you can refer to this.browserbot.getCurrentWindow() and if you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("foo") where "foo" is your locator.


storeEval(script, variableName)
Generated from getEval(script)
Arguments:
• script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object, and window will refer to the top-level runner test window, not the window of your application.
If you need a reference to the window of your application, you can refer to this.browserbot.getCurrentWindow() and if you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("foo") where "foo" is your locator.


storeExpression(expression, variableName)
Generated from getExpression(expression)
Arguments:
• expression - the value to return
Returns:
the value passed in
Returns the specified expression.
This is useful because of JavaScript preprocessing. It is used to generate commands like assertExpression and waitForExpression.


storeHtmlSource(variableName)
Generated from getHtmlSource()
Returns:
the entire HTML source
Returns the entire HTML source between the opening and closing "html" tags.


storeLocation(variableName)
Generated from getLocation()
Returns:
the absolute URL of the current page
Gets the absolute URL of the current page.


storeLogMessages(variableName)
Generated from getLogMessages()
Returns:
all log messages seen since the last call to this API
Return the contents of the log.
This is a placeholder intended to make the code generator make this API available to clients. The selenium server will intercept this call, however, and return its recordkeeping of log messages since the last call to this API. Thus this code in JavaScript will never be called.
The reason I opted for a servercentric solution is to be able to support multiple frames served from different domains, which would break a centralized JavaScript logging mechanism under some conditions.


storeMouseSpeed(variableName)
Generated from getMouseSpeed()
Returns:
the number of pixels between "mousemove" events during dragAndDrop commands (default=10)
Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).


storeOrdered(locator1, locator2, variableName)
Generated from isOrdered(locator1, locator2)
Arguments:
• locator1 - an element locator pointing to the first element
• locator2 - an element locator pointing to the second element
Returns:
true if two elements are ordered and have same parent, false otherwise
Check if these two elements have same parent and are ordered. Two same elements will not be considered ordered.


storePrompt(variableName)
Generated from getPrompt()
Returns:
the message of the most recent JavaScript question prompt
Retrieves the message of a JavaScript question prompt dialog generated during the previous action.
Successful handling of the prompt requires prior execution of the answerOnNextPrompt command. If a prompt is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript prompts will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript prompts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.


storePromptPresent(variableName)
Generated from isPromptPresent()
Returns:
true if there is a pending prompt
Has a prompt occurred?
This function never throws an exception


storeSelectOptions(selectLocator, variableName)
Generated from getSelectOptions(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all option labels in the specified select drop-down
Gets all option labels in the specified select drop-down.


storeSelectedId(selectLocator, variableName)
Generated from getSelectedId(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option ID in the specified select drop-down
Gets option element ID for selected option in the specified select element.


storeSelectedIds(selectLocator, variableName)
Generated from getSelectedIds(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option IDs in the specified select drop-down
Gets all option element IDs for selected options in the specified select or multi-select element.


storeSelectedIndex(selectLocator, variableName)
Generated from getSelectedIndex(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option index in the specified select drop-down
Gets option index (option number, starting at 0) for selected option in the specified select element.


storeSelectedIndexes(selectLocator, variableName)
Generated from getSelectedIndexes(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option indexes in the specified select drop-down
Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.


storeSelectedLabel(selectLocator, variableName)
Generated from getSelectedLabel(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option label in the specified select drop-down
Gets option label (visible text) for selected option in the specified select element.


storeSelectedLabels(selectLocator, variableName)
Generated from getSelectedLabels(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option labels in the specified select drop-down
Gets all option labels (visible text) for selected options in the specified select or multi-select element.


storeSelectedValue(selectLocator, variableName)
Generated from getSelectedValue(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option value in the specified select drop-down
Gets option value (value attribute) for selected option in the specified select element.


storeSelectedValues(selectLocator, variableName)
Generated from getSelectedValues(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option values in the specified select drop-down
Gets all option values (value attributes) for selected options in the specified select or multi-select element.


storeTable(tableCellAddress, variableName)
Generated from getTable(tableCellAddress)
Arguments:
• tableCellAddress - a cell address, e.g. "foo.1.4"
Returns:
the text from the specified cell
Gets the text from a cell of a table. The cellAddress syntax tableLocator.row.column, where row and column start at 0.


storeText(locator, variableName)
Generated from getText(locator)
Arguments:
• locator - an element locator
Returns:
the text of the element
Gets the text of an element. This works for any element that contains text. This command uses either the textContent (Mozilla-like browsers) or the innerText (IE-like browsers) of the element, which is the rendered text shown to the user.



storeTextPresent(pattern, variableName)
Generated from isTextPresent(pattern)
Arguments:
• pattern - a pattern to match with the text of the page
Returns:
true if the pattern matches the text, false otherwise
Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.


storeTitle(variableName)
Generated from getTitle()
Returns:
the title of the current page
Gets the title of the current page.


storeValue(locator, variableName)
Generated from getValue(locator)
Arguments:
• locator - an element locator
Returns:
the element value, or "on/off" for checkbox/radio elements
Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter). For checkbox/radio elements, the value will be "on" or "off" depending on whether the element is checked or not.


storeVisible(locator, variableName)
Generated from isVisible(locator)
Arguments:
• locator - an element locator
Returns:
true if the specified element is visible, false otherwise
Determines if the specified element is visible. An element can be rendered invisible by setting the CSS "visibility" property to "hidden", or the "display" property to "none", either for the element itself or one if its ancestors. This method will fail if the element is not present.


storeWhetherThisFrameMatchFrameExpression(currentFrameString, target, variableName)
Generated from getWhetherThisFrameMatchFrameExpression(currentFrameString, target)
Arguments:
• currentFrameString - starting frame
• target - new frame (which might be relative to the current one)
Returns:
true if the new frame is this code's window
Determine whether current/locator identify the frame containing this running code.
This is useful in proxy injection mode, where this code runs in every browser frame and window, and sometimes the selenium server needs to identify the "current" frame. In this case, when the test calls selectFrame, this routine is called for each frame to figure out which one has been selected. The selected frame will return true, while all others will return false.


storeWhetherThisWindowMatchWindowExpression(currentWindowString, target, variableName)
Generated from getWhetherThisWindowMatchWindowExpression(currentWindowString, target)
Arguments:
• currentWindowString - starting window
• target - new window (which might be relative to the current one, e.g., "_parent")
Returns:
true if the new window is this code's window
Determine whether currentWindowString plus target identify the window containing this running code.
This is useful in proxy injection mode, where this code runs in every browser frame and window, and sometimes the selenium server needs to identify the "current" window. In this case, when the test calls selectWindow, this routine is called for each window to figure out which one has been selected. The selected window will return true, while all others will return false.


submit(formLocator)
Arguments:
• formLocator - an element locator for the form you want to submit
Submit the specified form. This is particularly useful for forms without submit buttons, e.g. single-input "Search" forms.


submitAndWait(formLocator)
Generated from submit(formLocator)
Arguments:
• formLocator - an element locator for the form you want to submit
Submit the specified form. This is particularly useful for forms without submit buttons, e.g. single-input "Search" forms.

Selenium Commands - Part 6

R


refresh()
Simulates the user clicking the "Refresh" button on their browser.


refreshAndWait()
Generated from refresh()
Simulates the user clicking the "Refresh" button on their browser.


removeAllSelections(locator)
Arguments:
• locator - an element locator identifying a multi-select box
Unselects all of the selected options in a multi-select element.


removeAllSelectionsAndWait(locator)
Generated from removeAllSelections(locator)
Arguments:
• locator - an element locator identifying a multi-select box
Unselects all of the selected options in a multi-select element.


removeSelection(locator, optionLocator)
Arguments:
• locator - an element locator identifying a multi-select box
• optionLocator - an option locator (a label by default)
Remove a selection from the set of selected options in a multi-select element using an option locator. @see #doSelect for details of option locators


removeSelectionAndWait(locator, optionLocator)
Generated from removeSelection(locator, optionLocator)
Arguments:
• locator - an element locator identifying a multi-select box
• optionLocator - an option locator (a label by default)
Remove a selection from the set of selected options in a multi-select element using an option locator. @see #doSelect for details of option locators

Selenium Commands - Part 5

O



open(url)
Arguments:
• url - the URL to open; may be relative or absolute
Opens an URL in the test frame. This accepts both relative and absolute URLs. The "open" command waits for the page to load before proceeding, ie. the "AndWait" suffix is implicit. Note: The URL must be on the same domain as the runner HTML due to security restrictions in the browser (Same Origin Policy). If you need to open an URL on another domain, use the Selenium Server to start a new browser session on that domain.


openWindow(url, windowID)
Arguments:
• url - the URL to open, which can be blank
• windowID - the JavaScript window ID of the window to select
Opens a popup window (if a window with that ID isn't already open). After opening the window, you'll need to select it using the selectWindow command.
This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example). In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using an empty (blank) url, like this: openWindow("", "myFunnyWindow").


openWindowAndWait(url, windowID)
Generated from openWindow(url, windowID)
Arguments:
• url - the URL to open, which can be blank
• windowID - the JavaScript window ID of the window to select
Opens a popup window (if a window with that ID isn't already open). After opening the window, you'll need to select it using the selectWindow command.
This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example). In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using an empty (blank) url, like this: openWindow("", "myFunnyWindow").






P

pause(waitTime)
Arguments:
• waitTime - the amount of time to sleep (in milliseconds)
Wait for the specified amount of time (in milliseconds)

Selenium Commands - Part 4

W

waitForAlert(pattern)
Generated from getAlert()
Returns:
The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.
NOTE: Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

waitForAlertNotPresent()
Generated from isAlertPresent()
Returns:
true if there is an alert
Has an alert occurred?
This function never throws an exception
* For ex if we take an application www.jobsahead.com here iam using this command to check for any alerts which is not present in an application.
In command box write the command: waitforAlertNotPresent
In Target write the alert which we want to observe
In Value type True
I gave “Girish” in the target which is not present in the application.

waitForAlertPresent()
Generated from isAlertPresent()
Returns:
true if there is an alert
Has an alert occurred?
This function never throws an exception


*waitForAllButtons(pattern)
Generated from getAllButtons()
Returns:
the IDs of all buttons on the page
Returns the IDs of all buttons on the page.
If a given button has no ID, it will appear as "" in this array.
Take an example: www.agencypro.com
If we give invalid user name and password it throws an alert error message which is in Java Script. And if we…………..
waitForAllFields(pattern)
Generated from getAllFields()
Returns:
the IDs of all field on the page
Returns the IDs of all input fields on the page.
If a given field has no ID, it will appear as "" in this array.
Suppose if we take an URL:www.naukri.com and we have to get all fields ID’s
And the
waitForAllLinks(pattern)
Generated from getAllLinks()
Returns:
the IDs of all links on the page
Returns the IDs of all links on the page.
If a given link has no ID, it will appear as "" in this array.

waitForAllWindowIds(pattern)
Generated from getAllWindowIds()
Returns:
the IDs of all windows that the browser knows about.
Returns the IDs of all windows that the browser knows about.

waitForAllWindowNames(pattern)
Generated from getAllWindowNames()
Returns:
the names of all windows that the browser knows about.
Returns the names of all windows that the browser knows about.

waitForAllWindowTitles(pattern)
Generated from getAllWindowTitles()
Returns:
the titles of all windows that the browser knows about.
Returns the titles of all windows that the browser knows about.

waitForAttribute(attributeLocator, pattern)
Generated from getAttribute(attributeLocator)
Arguments:
• attributeLocator - an element locator followed by an
Returns:
the value of the specified attribute
Gets the value of an element attribute.

waitForAttributeFromAllWindows(attributeName, pattern)
Generated from getAttributeFromAllWindows(attributeName)
Arguments:
• attributeName - name of an attribute on the windows
Returns:
the set of values of this attribute from all known windows.
Returns every instance of some attribute from all known windows.

waitForBodyText(pattern)
Generated from getBodyText()
Returns:
the entire text of the page
Gets the entire text of the page.

waitForChecked(locator)
Generated from isChecked(locator)
Arguments:
• locator - an element locator pointing to a checkbox or radio button
Returns:
true if the checkbox is checked, false otherwise
Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.

waitForCondition(script, timeout)
Arguments:
• script - the JavaScript snippet to run
• timeout - a timeout in milliseconds, after which this command will return with an error
Runs the specified JavaScript snippet repeatedly until it evaluates to "true". The snippet may have multiple lines, but only the result of the last line will be considered.
Note that, by default, the snippet will be run in the runner's test window, not in the window of your application. To get the window of your application, you can use the JavaScript snippet selenium.browserbot.getCurrentWindow(), and then run your JavaScript in there

waitForConfirmation(pattern)
Generated from getConfirmation()
Returns:
the message of the most recent JavaScript confirmation dialog
Retrieves the message of a JavaScript confirmation dialog generated during the previous action.
By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command. If an confirmation is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.

waitForConfirmationNotPresent()
Generated from isConfirmationPresent()
Returns:
true if there is a pending confirmation
Has confirm() been called?
This function never throws an exception

waitForConfirmationPresent()
Generated from isConfirmationPresent()
Returns:
true if there is a pending confirmation
Has confirm() been called?
This function never throws an exception

waitForCookie(pattern)
Generated from getCookie()
Returns:
all cookies of the current page under test
Return all cookies of the current page under test.

waitForCursorPosition(locator, pattern)
Generated from getCursorPosition(locator)
Arguments:
• locator - an element locator pointing to an input element or textarea
Returns:
the numerical position of the cursor in the field
Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.

waitForEditable(locator)
Generated from isEditable(locator)
Arguments:
• locator - an element locator
Returns:
true if the input element is editable, false otherwise
Determines whether the specified input element is editable, ie hasn't been disabled. This method will fail if the specified element isn't an input element.

waitForElementHeight(locator, pattern)
Generated from getElementHeight(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
height of an element in pixels
Retrieves the height of an element

waitForElementIndex(locator, pattern)
Generated from getElementIndex(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
of relative index of the element to its parent (starting from 0)
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.

waitForElementNotPresent(locator)
Generated from isElementPresent(locator)
Arguments:
• locator - an element locator
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.

waitForElementPositionLeft(locator, pattern)
Generated from getElementPositionLeft(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the horizontal position of an element

waitForElementPositionTop(locator, pattern)
Generated from getElementPositionTop(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the vertical position of an element

waitForElementPresent(locator)
Generated from isElementPresent(locator)
Arguments:
• locator - an element locator
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.

waitForElementWidth(locator, pattern)
Generated from getElementWidth(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
width of an element in pixels
Retrieves the width of an element

waitForEval(script, pattern)
Generated from getEval(script)
Arguments:
• script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object, and window will refer to the top-level runner test window, not the window of your application.
If you need a reference to the window of your application, you can refer to this.browserbot.getCurrentWindow() and if you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("foo") where "foo" is your locator.

waitForExpression(expression, pattern)
Generated from getExpression(expression)
Arguments:
• expression - the value to return
Returns:
the value passed in
Returns the specified expression.
This is useful because of JavaScript preprocessing. It is used to generate commands like assertExpression and waitForExpression.

waitForHtmlSource(pattern)
Generated from getHtmlSource()
Returns:
the entire HTML source
Returns the entire HTML source between the opening and closing "html" tags.

waitForLocation(pattern)
Generated from getLocation()
Returns:
the absolute URL of the current page
Gets the absolute URL of the current page.

waitForLogMessages(pattern)
Generated from getLogMessages()
Returns:
all log messages seen since the last call to this API
Return the contents of the log.
This is a placeholder intended to make the code generator make this API available to clients. The selenium server will intercept this call, however, and return its recordkeeping of log messages since the last call to this API. Thus this code in JavaScript will never be called.
The reason I opted for a servercentric solution is to be able to support multiple frames served from different domains, which would break a centralized JavaScript logging mechanism under some conditions.

waitForMouseSpeed(pattern)
Generated from getMouseSpeed()
Returns:
the number of pixels between "mousemove" events during dragAndDrop commands (default=10)
Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).

waitForNotAlert(pattern)
Generated from getAlert()
Returns:
The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.
NOTE: Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

waitForNotAllButtons(pattern)
Generated from getAllButtons()
Returns:
the IDs of all buttons on the page
Returns the IDs of all buttons on the page.
If a given button has no ID, it will appear as "" in this array.

waitForNotAllFields(pattern)
Generated from getAllFields()
Returns:
the IDs of all field on the page
Returns the IDs of all input fields on the page.
If a given field has no ID, it will appear as "" in this array.

waitForNotAllLinks(pattern)
Generated from getAllLinks()
Returns:
the IDs of all links on the page
Returns the IDs of all links on the page.
If a given link has no ID, it will appear as "" in this array.

waitForNotAllWindowIds(pattern)
Generated from getAllWindowIds()
Returns:
the IDs of all windows that the browser knows about.
Returns the IDs of all windows that the browser knows about.

waitForNotAllWindowNames(pattern)
Generated from getAllWindowNames()
Returns:
the names of all windows that the browser knows about.
Returns the names of all windows that the browser knows about.

waitForNotAllWindowTitles(pattern)
Generated from getAllWindowTitles()
Returns:
the titles of all windows that the browser knows about.
Returns the titles of all windows that the browser knows about.

waitForNotAttribute(attributeLocator, pattern)
Generated from getAttribute(attributeLocator)
Arguments:
• attributeLocator - an element locator followed by an
Returns:
the value of the specified attribute
Gets the value of an element attribute.

waitForNotAttributeFromAllWindows(attributeName, pattern)
Generated from getAttributeFromAllWindows(attributeName)
Arguments:
• attributeName - name of an attribute on the windows
Returns:
the set of values of this attribute from all known windows.
Returns every instance of some attribute from all known windows.

waitForNotBodyText(pattern)
Generated from getBodyText()
Returns:
the entire text of the page
Gets the entire text of the page.

waitForNotChecked(locator)
Generated from isChecked(locator)
Arguments:
• locator - an element locator pointing to a checkbox or radio button
Returns:
true if the checkbox is checked, false otherwise
Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.

waitForNotConfirmation(pattern)
Generated from getConfirmation()
Returns:
the message of the most recent JavaScript confirmation dialog
Retrieves the message of a JavaScript confirmation dialog generated during the previous action.
By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command. If an confirmation is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.

waitForNotCookie(pattern)
Generated from getCookie()
Returns:
all cookies of the current page under test
Return all cookies of the current page under test.

waitForNotCursorPosition(locator, pattern)
Generated from getCursorPosition(locator)
Arguments:
• locator - an element locator pointing to an input element or textarea
Returns:
the numerical position of the cursor in the field
Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.

waitForNotEditable(locator)
Generated from isEditable(locator)
Arguments:
• locator - an element locator
Returns:
true if the input element is editable, false otherwise
Determines whether the specified input element is editable, ie hasn't been disabled. This method will fail if the specified element isn't an input element.

waitForNotElementHeight(locator, pattern)
Generated from getElementHeight(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
height of an element in pixels
Retrieves the height of an element

waitForNotElementIndex(locator, pattern)
Generated from getElementIndex(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
of relative index of the element to its parent (starting from 0)
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.

waitForNotElementPositionLeft(locator, pattern)
Generated from getElementPositionLeft(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the horizontal position of an element

waitForNotElementPositionTop(locator, pattern)
Generated from getElementPositionTop(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the vertical position of an element

waitForNotElementWidth(locator, pattern)
Generated from getElementWidth(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
width of an element in pixels
Retrieves the width of an element

waitForNotEval(script, pattern)
Generated from getEval(script)
Arguments:
• script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object, and window will refer to the top-level runner test window, not the window of your application.
If you need a reference to the window of your application, you can refer to this.browserbot.getCurrentWindow() and if you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("foo") where "foo" is your locator.

waitForNotExpression(expression, pattern)
Generated from getExpression(expression)
Arguments:
• expression - the value to return
Returns:
the value passed in
Returns the specified expression.
This is useful because of JavaScript preprocessing. It is used to generate commands like assertExpression and waitForExpression.

waitForNotHtmlSource(pattern)
Generated from getHtmlSource()
Returns:
the entire HTML source
Returns the entire HTML source between the opening and closing "html" tags.

waitForNotLocation(pattern)
Generated from getLocation()
Returns:
the absolute URL of the current page
Gets the absolute URL of the current page.

waitForNotLogMessages(pattern)
Generated from getLogMessages()
Returns:
all log messages seen since the last call to this API
Return the contents of the log.
This is a placeholder intended to make the code generator make this API available to clients. The selenium server will intercept this call, however, and return its recordkeeping of log messages since the last call to this API. Thus this code in JavaScript will never be called.
The reason I opted for a servercentric solution is to be able to support multiple frames served from different domains, which would break a centralized JavaScript logging mechanism under some conditions.

waitForNotMouseSpeed(pattern)
Generated from getMouseSpeed()
Returns:
the number of pixels between "mousemove" events during dragAndDrop commands (default=10)
Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).

waitForNotOrdered(locator1, locator2)
Generated from isOrdered(locator1, locator2)
Arguments:
• locator1 - an element locator pointing to the first element
• locator2 - an element locator pointing to the second element
Returns:
true if two elements are ordered and have same parent, false otherwise
Check if these two elements have same parent and are ordered. Two same elements will not be considered ordered.

waitForNotPrompt(pattern)
Generated from getPrompt()
Returns:
the message of the most recent JavaScript question prompt
Retrieves the message of a JavaScript question prompt dialog generated during the previous action.
Successful handling of the prompt requires prior execution of the answerOnNextPrompt command. If a prompt is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript prompts will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript prompts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

waitForNotSelectOptions(selectLocator, pattern)
Generated from getSelectOptions(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all option labels in the specified select drop-down
Gets all option labels in the specified select drop-down.

waitForNotSelectedId(selectLocator, pattern)
Generated from getSelectedId(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option ID in the specified select drop-down
Gets option element ID for selected option in the specified select element.

waitForNotSelectedIds(selectLocator, pattern)
Generated from getSelectedIds(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option IDs in the specified select drop-down
Gets all option element IDs for selected options in the specified select or multi-select element.

waitForNotSelectedIndex(selectLocator, pattern)
Generated from getSelectedIndex(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option index in the specified select drop-down
Gets option index (option number, starting at 0) for selected option in the specified select element.

waitForNotSelectedIndexes(selectLocator, pattern)
Generated from getSelectedIndexes(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option indexes in the specified select drop-down
Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.

waitForNotSelectedLabel(selectLocator, pattern)
Generated from getSelectedLabel(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option label in the specified select drop-down
Gets option label (visible text) for selected option in the specified select element.

waitForNotSelectedLabels(selectLocator, pattern)
Generated from getSelectedLabels(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option labels in the specified select drop-down
Gets all option labels (visible text) for selected options in the specified select or multi-select element.

waitForNotSomethingSelected(selectLocator)
Generated from isSomethingSelected(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
true if some option has been selected, false otherwise
Determines whether some option in a drop-down menu is selected.

waitForNotTable(tableCellAddress, pattern)
Generated from getTable(tableCellAddress)
Arguments:
• tableCellAddress - a cell address, e.g. "foo.1.4"
Returns:
the text from the specified cell
Gets the text from a cell of a table. The cellAddress syntax tableLocator.row.column, where row and column start at 0.

waitForNotText(locator, pattern)
Generated from getText(locator)
Arguments:
• locator - an element locator
Returns:
the text of the element
Gets the text of an element. This works for any element that contains text. This command uses either the textContent (Mozilla-like browsers) or the innerText (IE-like browsers) of the element, which is the rendered text shown to the user.

waitForNotTitle(pattern)
Generated from getTitle()
Returns:
the title of the current page
Gets the title of the current page.

waitForNotValue(locator, pattern)
Generated from getValue(locator)
Arguments:
• locator - an element locator
Returns:
the element value, or "on/off" for checkbox/radio elements
Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter). For checkbox/radio elements, the value will be "on" or "off" depending on whether the element is checked or not.

waitForNotVisible(locator)
Generated from isVisible(locator)
Arguments:
• locator - an element locator
Returns:
true if the specified element is visible, false otherwise
Determines if the specified element is visible. An element can be rendered invisible by setting the CSS "visibility" property to "hidden", or the "display" property to "none", either for the element itself or one if its ancestors. This method will fail if the element is not present.

waitForNotWhetherThisFrameMatchFrameExpression(currentFrameString, target, pattern)
Generated from getWhetherThisFrameMatchFrameExpression(currentFrameString, target)
Arguments:
• currentFrameString - starting frame
• target - new frame (which might be relative to the current one)
Returns:
true if the new frame is this code's window
Determine whether current/locator identify the frame containing this running code.
This is useful in proxy injection mode, where this code runs in every browser frame and window, and sometimes the selenium server needs to identify the "current" frame. In this case, when the test calls selectFrame, this routine is called for each frame to figure out which one has been selected. The selected frame will return true, while all others will return false.

waitForNotWhetherThisWindowMatchWindowExpression(currentWindowString, target, pattern)
Generated from getWhetherThisWindowMatchWindowExpression(currentWindowString, target)
Arguments:
• currentWindowString - starting window
• target - new window (which might be relative to the current one, e.g., "_parent")
Returns:
true if the new window is this code's window
Determine whether currentWindowString plus target identify the window containing this running code.
This is useful in proxy injection mode, where this code runs in every browser frame and window, and sometimes the selenium server needs to identify the "current" window. In this case, when the test calls selectWindow, this routine is called for each window to figure out which one has been selected. The selected window will return true, while all others will return false.

windowFocus(windowName)
Arguments:
• windowName - name of the window to be given focus
Gives focus to a window

windowFocusAndWait(windowName)
Generated from windowFocus(windowName)
Arguments:
• windowName - name of the window to be given focus
Gives focus to a window

windowMaximize(windowName)
Arguments:
• windowName - name of the window to be enlarged
Resize window to take up the entire screen

windowMaximizeAndWait(windowName)
Generated from windowMaximize(windowName)
Arguments:
• windowName - name of the window to be enlarged
Resize window to take up the entire screen

Selenium Commands - Part 3

v

verifyAlert(pattern)
Generated from getAlert()
Returns:
The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.
NOTE: Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

verifyAlertNotPresent()
Generated from isAlertPresent()
Returns:
true if there is an alert
Has an alert occurred?
This function never throws an exception


verifyAlertPresent()
Generated from isAlertPresent()
Returns:
true if there is an alert
Has an alert occurred?
This function never throws an exception


verifyAllButtons(pattern)
Generated from getAllButtons()
Returns:
the IDs of all buttons on the page
Returns the IDs of all buttons on the page.
If a given button has no ID, it will appear as "" in this array.


verifyAllFields(pattern)
Generated from getAllFields()
Returns:
the IDs of all field on the page
Returns the IDs of all input fields on the page.
If a given field has no ID, it will appear as "" in this array.


verifyAllLinks(pattern)
Generated from getAllLinks()
Returns:
the IDs of all links on the page
Returns the IDs of all links on the page.
If a given link has no ID, it will appear as "" in this array.


verifyAllWindowIds(pattern)
Generated from getAllWindowIds()
Returns:
the IDs of all windows that the browser knows about.
Returns the IDs of all windows that the browser knows about.


verifyAllWindowNames(pattern)
Generated from getAllWindowNames()
Returns:
the names of all windows that the browser knows about.
Returns the names of all windows that the browser knows about.


verifyAllWindowTitles(pattern)
Generated from getAllWindowTitles()
Returns:
the titles of all windows that the browser knows about.
Returns the titles of all windows that the browser knows about.


verifyAttribute(attributeLocator, pattern)
Generated from getAttribute(attributeLocator)
Arguments:
• attributeLocator - an element locator followed by an
Returns:
the value of the specified attribute
Gets the value of an element attribute.


verifyAttributeFromAllWindows(attributeName, pattern)
Generated from getAttributeFromAllWindows(attributeName)
Arguments:
• attributeName - name of an attribute on the windows
Returns:
the set of values of this attribute from all known windows.
Returns every instance of some attribute from all known windows.


verifyBodyText(pattern)
Generated from getBodyText()
Returns:
the entire text of the page
Gets the entire text of the page.


verifyChecked(locator)
Generated from isChecked(locator)
Arguments:
• locator - an element locator pointing to a checkbox or radio button
Returns:
true if the checkbox is checked, false otherwise
Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.

verifyConfirmation(pattern)
Generated from getConfirmation()
Returns:
the message of the most recent JavaScript confirmation dialog
Retrieves the message of a JavaScript confirmation dialog generated during the previous action.
By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command. If an confirmation is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.

verifyConfirmationNotPresent()
Generated from isConfirmationPresent()
Returns:
true if there is a pending confirmation
Has confirm() been called?
This function never throws an exception

verifyConfirmationPresent()
Generated from isConfirmationPresent()
Returns:
true if there is a pending confirmation
Has confirm() been called?
This function never throws an exception

verifyCookie(pattern)
Generated from getCookie()
Returns:
all cookies of the current page under test
Return all cookies of the current page under test.

verifyCursorPosition(locator, pattern)
Generated from getCursorPosition(locator)
Arguments:
• locator - an element locator pointing to an input element or textarea
Returns:
the numerical position of the cursor in the field
Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.

verifyEditable(locator)
Generated from isEditable(locator)
Arguments:
• locator - an element locator
Returns:
true if the input element is editable, false otherwise
Determines whether the specified input element is editable, ie hasn't been disabled. This method will fail if the specified element isn't an input element.

verifyElementHeight(locator, pattern)
Generated from getElementHeight(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
height of an element in pixels
Retrieves the height of an element


verifyElementIndex(locator, pattern)
Generated from getElementIndex(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
of relative index of the element to its parent (starting from 0)
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.


verifyElementNotPresent(locator)
Generated from isElementPresent(locator)
Arguments:
• locator - an element locator
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.


verifyElementPositionLeft(locator, pattern)
Generated from getElementPositionLeft(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the horizontal position of an element


verifyElementPositionTop(locator, pattern)
Generated from getElementPositionTop(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the vertical position of an element


verifyElementPresent(locator)
Generated from isElementPresent(locator)
Arguments:
• locator - an element locator
Returns:
true if the element is present, false otherwise
Verifies that the specified element is somewhere on the page.

verifyElementWidth(locator, pattern)
Generated from getElementWidth(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
width of an element in pixels
Retrieves the width of an element

verifyEval(script, pattern)
Generated from getEval(script)
Arguments:
• script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object, and window will refer to the top-level runner test window, not the window of your application.
If you need a reference to the window of your application, you can refer to this.browserbot.getCurrentWindow() and if you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("foo") where "foo" is your locator.

verifyExpression(expression, pattern)
Generated from getExpression(expression)
Arguments:
• expression - the value to return
Returns:
the value passed in
Returns the specified expression.
This is useful because of JavaScript preprocessing. It is used to generate commands like assertExpression and waitForExpression.

verifyHtmlSource(pattern)
Generated from getHtmlSource()
Returns:
the entire HTML source
Returns the entire HTML source between the opening and closing "html" tags.

verifyLocation(pattern)
Generated from getLocation()
Returns:
the absolute URL of the current page
Gets the absolute URL of the current page.

verifyLogMessages(pattern)
Generated from getLogMessages()
Returns:
all log messages seen since the last call to this API
Return the contents of the log.
This is a placeholder intended to make the code generator make this API available to clients. The selenium server will intercept this call, however, and return its recordkeeping of log messages since the last call to this API. Thus this code in JavaScript will never be called.
The reason I opted for a servercentric solution is to be able to support multiple frames served from different domains, which would break a centralized JavaScript logging mechanism under some conditions.

verifyMouseSpeed(pattern)
Generated from getMouseSpeed()
Returns:
the number of pixels between "mousemove" events during dragAndDrop commands (default=10)
Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).

verifyNotAlert(pattern)
Generated from getAlert()
Returns:
The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.
NOTE: Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

verifyNotAllButtons(pattern)
Generated from getAllButtons()
Returns:
the IDs of all buttons on the page
Returns the IDs of all buttons on the page.
If a given button has no ID, it will appear as "" in this array.

verifyNotAllFields(pattern)
Generated from getAllFields()
Returns:
the IDs of all field on the page
Returns the IDs of all input fields on the page.
If a given field has no ID, it will appear as "" in this array.

verifyNotAllLinks(pattern)
Generated from getAllLinks()
Returns:
the IDs of all links on the page
Returns the IDs of all links on the page.
If a given link has no ID, it will appear as "" in this array.

verifyNotAllWindowIds(pattern)
Generated from getAllWindowIds()
Returns:
the IDs of all windows that the browser knows about.
Returns the IDs of all windows that the browser knows about.

verifyNotAllWindowNames(pattern)
Generated from getAllWindowNames()
Returns:
the names of all windows that the browser knows about.
Returns the names of all windows that the browser knows about.

verifyNotAllWindowTitles(pattern)
Generated from getAllWindowTitles()
Returns:
the titles of all windows that the browser knows about.
Returns the titles of all windows that the browser knows about.

verifyNotAttribute(attributeLocator, pattern)
Generated from getAttribute(attributeLocator)
Arguments:
• attributeLocator - an element locator followed by an
Returns:
the value of the specified attribute
Gets the value of an element attribute.

verifyNotAttributeFromAllWindows(attributeName, pattern)
Generated from getAttributeFromAllWindows(attributeName)
Arguments:
• attributeName - name of an attribute on the windows
Returns:
the set of values of this attribute from all known windows.
Returns every instance of some attribute from all known windows.

verifyNotBodyText(pattern)
Generated from getBodyText()
Returns:
the entire text of the page
Gets the entire text of the page.

verifyNotChecked(locator)
Generated from isChecked(locator)
Arguments:
• locator - an element locator pointing to a checkbox or radio button
Returns:
true if the checkbox is checked, false otherwise
Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.

verifyNotConfirmation(pattern)
Generated from getConfirmation()
Returns:
the message of the most recent JavaScript confirmation dialog
Retrieves the message of a JavaScript confirmation dialog generated during the previous action.
By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command. If an confirmation is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.

verifyNotCookie(pattern)
Generated from getCookie()
Returns:
all cookies of the current page under test
Return all cookies of the current page under test.

verifyNotCursorPosition(locator, pattern)
Generated from getCursorPosition(locator)
Arguments:
• locator - an element locator pointing to an input element or textarea
Returns:
the numerical position of the cursor in the field
Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.

verifyNotEditable(locator)
Generated from isEditable(locator)
Arguments:
• locator - an element locator
Returns:
true if the input element is editable, false otherwise
Determines whether the specified input element is editable, ie hasn't been disabled. This method will fail if the specified element isn't an input element.

verifyNotElementHeight(locator, pattern)
Generated from getElementHeight(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
height of an element in pixels
Retrieves the height of an element

verifyNotElementIndex(locator, pattern)
Generated from getElementIndex(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
of relative index of the element to its parent (starting from 0)
Get the relative index of an element to its parent (starting from 0). The comment node and empty text node will be ignored.

verifyNotElementPositionLeft(locator, pattern)
Generated from getElementPositionLeft(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the horizontal position of an element

verifyNotElementPositionTop(locator, pattern)
Generated from getElementPositionTop(locator)
Arguments:
• locator - an element locator pointing to an element OR an element itself
Returns:
of pixels from the edge of the frame.
Retrieves the vertical position of an element

verifyNotElementWidth(locator, pattern)
Generated from getElementWidth(locator)
Arguments:
• locator - an element locator pointing to an element
Returns:
width of an element in pixels
Retrieves the width of an element

verifyNotEval(script, pattern)
Generated from getEval(script)
Arguments:
• script - the JavaScript snippet to run
Returns:
the results of evaluating the snippet
Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the snippet will run in the context of the "selenium" object itself, so this will refer to the Selenium object, and window will refer to the top-level runner test window, not the window of your application.
If you need a reference to the window of your application, you can refer to this.browserbot.getCurrentWindow() and if you need to use a locator to refer to a single element in your application page, you can use this.browserbot.findElement("foo") where "foo" is your locator.

verifyNotExpression(expression, pattern)
Generated from getExpression(expression)
Arguments:
• expression - the value to return
Returns:
the value passed in
Returns the specified expression.
This is useful because of JavaScript preprocessing. It is used to generate commands like assertExpression and waitForExpression.

verifyNotHtmlSource(pattern)
Generated from getHtmlSource()
Returns:
the entire HTML source
Returns the entire HTML source between the opening and closing "html" tags.

verifyNotLocation(pattern)
Generated from getLocation()
Returns:
the absolute URL of the current page
Gets the absolute URL of the current page.

verifyNotLogMessages(pattern)
Generated from getLogMessages()
Returns:
all log messages seen since the last call to this API
Return the contents of the log.
This is a placeholder intended to make the code generator make this API available to clients. The selenium server will intercept this call, however, and return its recordkeeping of log messages since the last call to this API. Thus this code in JavaScript will never be called.
The reason I opted for a servercentric solution is to be able to support multiple frames served from different domains, which would break a centralized JavaScript logging mechanism under some conditions.

verifyNotMouseSpeed(pattern)
Generated from getMouseSpeed()
Returns:
the number of pixels between "mousemove" events during dragAndDrop commands (default=10)
Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).

verifyNotOrdered(locator1, locator2)
Generated from isOrdered(locator1, locator2)
Arguments:
• locator1 - an element locator pointing to the first element
• locator2 - an element locator pointing to the second element
Returns:
true if two elements are ordered and have same parent, false otherwise
Check if these two elements have same parent and are ordered. Two same elements will not be considered ordered.


verifyNotPrompt(pattern)
Generated from getPrompt()
Returns:
the message of the most recent JavaScript question prompt
Retrieves the message of a JavaScript question prompt dialog generated during the previous action.
Successful handling of the prompt requires prior execution of the answerOnNextPrompt command. If a prompt is generated but you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript prompts will NOT pop up a visible dialog.
NOTE: Selenium does NOT support JavaScript prompts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

verifyNotSelectOptions(selectLocator, pattern)
Generated from getSelectOptions(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all option labels in the specified select drop-down
Gets all option labels in the specified select drop-down.

verifyNotSelectedId(selectLocator, pattern)
Generated from getSelectedId(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option ID in the specified select drop-down
Gets option element ID for selected option in the specified select element.


verifyNotSelectedIds(selectLocator, pattern)
Generated from getSelectedIds(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option IDs in the specified select drop-down
Gets all option element IDs for selected options in the specified select or multi-select element.

verifyNotSelectedIndex(selectLocator, pattern)
Generated from getSelectedIndex(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option index in the specified select drop-down
Gets option index (option number, starting at 0) for selected option in the specified select element.


verifyNotSelectedIndexes(selectLocator, pattern)
Generated from getSelectedIndexes(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option indexes in the specified select drop-down
Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.

verifyNotSelectedLabel(selectLocator, pattern)
Generated from getSelectedLabel(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option label in the specified select drop-down
Gets option label (visible text) for selected option in the specified select element.

verifyNotSelectedValue(selectLocator, pattern)
Generated from getSelectedValue(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
the selected option value in the specified select drop-down
Gets option value (value attribute) for selected option in the specified select element.

verifyNotSelectedValues(selectLocator, pattern)
Generated from getSelectedValues(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
an array of all selected option values in the specified select drop-down
Gets all option values (value attributes) for selected options in the specified select or multi-select element.

verifyNotSomethingSelected(selectLocator)
Generated from isSomethingSelected(selectLocator)
Arguments:
• selectLocator - an element locator identifying a drop-down menu
Returns:
true if some option has been selected, false otherwise
Determines whether some option in a drop-down menu is selected.

verifyNotTable(tableCellAddress, pattern)
Generated from getTable(tableCellAddress)
Arguments:
• tableCellAddress - a cell address, e.g. "foo.1.4"
Returns:
the text from the specified cell
Gets the text from a cell of a table. The cellAddress syntax tableLocator.row.column, where row and column start at 0.

verifyNotText(locator, pattern)
Generated from getText(locator)
Arguments:
• locator - an element locator
Returns:
the text of the element
Gets the text of an element. This works for any element that contains text. This command uses either the textContent (Mozilla-like browsers) or the innerText (IE-like browsers) of the element, which is the rendered text shown to the user.

verifyNotTitle(pattern)
Generated from getTitle()
Returns:
the title of the current page
Gets the title of the current page.

verifyNotValue(locator, pattern)
Generated from getValue(locator)
Arguments:
• locator - an element locator
Returns:
the element value, or "on/off" for checkbox/radio elements
Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter). For checkbox/radio elements, the value will be "on" or "off" depending on whether the element is checked or not.

verifyNotVisible(locator)
Generated from isVisible(locator)
Arguments:
• locator - an element locator
Returns:
true if the specified element is visible, false otherwise
Determines if the specified element is visible. An element can be rendered invisible by setting the CSS "visibility" property to "hidden", or the "display" property to "none", either for the element itself or one if its ancestors. This method will fail if the element is not present.

verifyNotWhetherThisFrameMatchFrameExpression(currentFrameString, target, pattern)
Generated from getWhetherThisFrameMatchFrameExpression(currentFrameString, target)
Arguments:
• currentFrameString - starting frame
• target - new frame (which might be relative to the current one)
Returns:
true if the new frame is this code's window
Determine whether current/locator identify the frame containing this running code.
This is useful in proxy injection mode, where this code runs in every browser frame and window, and sometimes the selenium server needs to identify the "current" frame. In this case, when the test calls selectFrame, this routine is called for each frame to figure out which one has been selected. The selected frame will return true, while all others will return false.

verifyNotWhetherThisWindowMatchWindowExpression(currentWindowString, target, pattern)
Generated from getWhetherThisWindowMatchWindowExpression(currentWindowString, target)
Arguments:
• currentWindowString - starting window
• target - new window (which might be relative to the current one, e.g., "_parent")
Returns:
true if the new window is this code's window
Determine whether currentWindowString plus target identify the window containing this running code.
This is useful in proxy injection mode, where this code runs in every browser frame and window, and sometimes the selenium server needs to identify the "current" window. In this case, when the test calls selectWindow, this routine is called for each window to figure out which one has been selected. The selected window will return true, while all others will return false.