Search This Blog

Wednesday, August 4, 2010

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