0% found this document useful (0 votes)
83 views12 pages

Selenium Tutorial Day 33 - Concepts

Uploaded by

Bhaskar Kodavala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views12 pages

Selenium Tutorial Day 33 - Concepts

Uploaded by

Bhaskar Kodavala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Portnov Computer School presents:

Selenium
Web Test Tool Training
Discover the automating power of Selenium

Presented by:
Kangeyan Passoubady (Kangs)

Copy Right: 2009-2011, All rights reserved by Kangeyan Passoubady (Kangs). Republishing requires author’s permission
3
Day

Selenium Concepts

Discover the automating power of


Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
Selenium Commands
●A command is what tells Selenium what to do.
●Selenium commands are broken down into 3

types:
●Actions – Command the browser to do
something
●Accessors – Store/retrieve data from selenium

variables
●Asserts – Verify that the browser is in a certain

state

Discover the automating power of


Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
Selenium Commands - Actions
●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.
Discover the automating power of
Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
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.

Discover the automating power of


Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
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).
Discover the automating power of
Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
Selenium Parameters
● 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:

●Id based,

●X-Path based, DOM Based

●CSS selector based

●Pattern matchers are typically exact matches

or regular expressions
Discover the automating power of
Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
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[0].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 "//“
●identifier, otherwise

Discover the automating power of


Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
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.
filterType=argument

● Supported element-filters are:


●Based on their values match elements. It is useful
for refining a list of similarly-named toggle-buttons.
● value=patternValue
●Selects a single element based on its position in
the list (starting from zero).
● index=indexValue

Discover the automating power of


Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
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.
●regexp:regexpValue: Match a string using a
regular-expression. The full power of JavaScript
regular-expression is available.
●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.

Discover the automating power of


Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
Selenium Recording Problem
●Why doesn't everything get recorded?
●Not every event will be recorded by

Selenium IDE.
●Usually the ones that won't be

recorded are those that involve complex


HTML (Hyper Text Markup Language)
and/or AJAX (Asynchronous JavaScript and
XML)
●Careful while testing HTTPS events
Discover the automating power of
Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *
Selenium Auto Complete Problem
● Why doesn't event triggered when I
select something from auto-complete
history?
●Auto-Complete does not trigger

Javascript event
●No event triggered means Selenium

IDE cannot record it


●Work Around: Manually type the input,

instead of selecting it from auto-complete


Discover the automating power of
Selenium Copyright © 2008-2011
Discover the automating power of Selenium
by Kangeyan Passoubady
Copyright © 2008-2011 by Kangeyan Passoubady (Kangs)
(Kangs) *

You might also like