On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
Selenium Tutorial Day 33 - ConceptsPresentation Transcript
Selenium Web Test Tool Training Discover the automating power of Selenium Portnov Computer School presents: Presented by: Kangeyan Passoubady (Kangs) Copy Right: 2009-2011, All rights reserved by Kangeyan Passoubady (Kangs). Republishing requires author’s permission
Actions are commands that generally manipulate the state of the application.
They do things like "click this link" and "select that option".
If an Action fails, or has an error, the execution of the current test is stopped.
Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait".
Action suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.
Selenium Commands - Accessors
Accessors examine the state of the application and store the results in variables, e.g. "storeTitle".
They are also used to automatically generate Assertions.
Selenium Commands - Assertions
Assertions are like Accessors, but they verify that the state of the application conforms to what is expected.
Examples include "make sure the page title is X" and "verify that this checkbox is checked".
All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor".
Example include, "assertText","verifyText" and "waitForText".
When an "assert" fails, the test is aborted. When a "verify" fails, the test will continue execution, logging the failure.
This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc.
"waitFor" commands wait for some condition to become true (which can be useful for testing Ajax applications).
Two types of Selenium Parameters
Locators – Used to find elements in html trees
Pattern Matchers – Used to verify values
Lots of locator types. Some examples are:
X-Path based, DOM Based
CSS selector based
Pattern matchers are typically exact matches or regular expressions
Selenium Element Locators
Element Locators tell Selenium which HTML element a command refers to.
Many commands require an Element Locator as the "target" attribute.
Examples of Element Locator's include "elementId" and "document.forms.element".
The format of a locator is: locatorType=argument.
To locate elements use identifier, id, name, DOM, CSS, XPath, and link. Without an explicit locator prefix, Selenium uses the following default strategies:
DOM, for locators starting with "document.“
XPath, for locators starting with "//“
Selenium Element Filters
Element filters can be used with a locator to refine a list of candidate elements.
They are currently used only in the 'name' element-locator. Filters look much like locators, i.e.
Supported element-filters are:
Based on their values match elements. It is useful for refining a list of similarly-named toggle-buttons.
Selects a single element based on its position in the list (starting from zero).
Selenium String Match Patterns
Various Pattern syntaxes are available for matching string values:
glob:patternValue: "Glob" is a limited regular expression syntax. Similar to DOS command-line wildcards. In a glob pattern, "*" represents any sequence of characters, and "?" represents any single character. Glob patterns match against the entire string.
exact:stringValue : Match a string value exactly, without using any wildcards.
If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern.
Selenium Recording Problem
Why doesn't everything get recorded?
Not every event will be recorded by Selenium IDE.
Careful while testing HTTPS events
Selenium Auto Complete Problem
Why doesn't event triggered when I select something from auto-complete history?
No event triggered means Selenium IDE cannot record it
Work Around: Manually type the input, instead of selecting it from auto-complete