Helps in declaring and assigning a value to variable
Ex:
Command : store
Target :1000
Value : a
Thiswill create a
variable ‘a’ andassign 1000 as its
value
Echo command
Helps in printing a value to the log. It can be character,
string, number or value of variable.
To print value of variable,
Command: echo;
Target: ${Variable Name}
Ex:
Command: echo
Target: $(a)
This will print value of variable ‘a’ that is 1000 to the
blog
Note:
If you simple give ‘a’ in the target instead of ‘${a}’ then
this is treated as a string/Character and ‘a’is printed to log but not its value.
All the variables declared in a test are stored into an
array called ‘storedVars’ .In order to refer value of variable inside
storedVars array, you can call Target: JavaScript {storedVars [‘a’]}
Command: echo
Target: JavaScript{storedVars[a]}
Command: echo
Target : storedVars[‘a’] to the log but not value of ‘a’
Assigning value ofvariable to another variable:
Command : store
Target :${a}
Value : b
Or
Command : store
Target: JavaScript{storedVars[a]}
Value: b
In both examples mentioned above , value of ‘a’ assigned to
variable ‘b’
storeEval Command:
UsingstoreEValCommandyou can directly assignor print
value of a variables withouthelp of
‘Javascript{}’ in thetarget
Ex:
Command : storeEVal
Target : storedVars{a}
Value : c
Observe thatin the
above examplewe are directlycalling storedVars[‘a’] to assign value to
variable ‘a’ to ‘c’
Many sites use dynamic values for element’s id attributes, which
can make them difficult to locate. One simple solution is to use XPath
functions and base the location on what you do know about the element. For
example, if your dynamic ids have the format <input id="text-12345" /> where 12345 is
a dynamic number you could use the following XPath://input[starts-with(@id, 'text-')]
contains
If an element can be located by a value that could be surrounded
by other text, the contains function can be used. To demonstrate, the
element <span class="top headingbold"> can
be located based on the ‘heading’ class without having to couple it with the ‘top’
and ‘bold’ classes using the following XPath: //span[contains(@class, 'heading')].
Incidentally, this would be much neater (and probably faster) using the CSS
locator strategycss=span.heading
siblings
Not yet written - locate elements based on their siblings. Useful
for forms and tables.
Starting to use CSS
instead of XPATH
Locating elements based
on class
In order to locate an element based on associated class in XPath
you must consider that the element could have multiple classes and defined in
any order. However with CSS locators this is much simpler (and faster).
XPath: //div[contains(@class, 'article-heading')]
CSS: css=div.article-heading
How to write XPATH for an element
for Selenium IDE?
.The purpose of it in Selenium is to locate an
element which can be used while writing a script in Selenium IDE.The XPATH when
written in Selenium is helpful in locating the element without fail.
Importance of XPATH in Selenium IDE
XPATH is useful in identifying and locating the page
elements with it's html information.Each and every html tag has XPATH for
it.It can be written for each and every html tag.When writing it you will be
using the html tags for reference.To get the XPATH of an element you
should install the Firebug in your Mozilla Firefox browser.It helps in
identifying the XPATH by using the HTML tags.As Selenium IDE runs on Mozilla
Firefox browser the Firebug is the tool which should be added to your browser
to make your work easier while writing XPATH.
How to write XPATH for Selenium IDE ?
It is written with the tags of the elements.
You can get the basic XPATH of an element by using the
Firebug which you have added to the Mozilla Firefox browser as an Add-On. To
get an XPATH of an element right click on the element and select "Inspect
element with Firebug". And when you happen to visit the element in the
Firebug right click on it and select copy XPATH. By this method you can copy the
XPATH and paste it in your Selenium IDE tool's Target section.
Waiting is having the automated task
execution elapse a certain amount of time before continuing with the next step.
Explicit
Waits
An explicit waits is code you define to wait
for a certain condition to occur before proceeding further in the code. The
worst case of this is Thread.sleep(), which sets the condition to an exact time
period to wait. There are some convenience methods provided that help you write
code that will wait only as long as required. WebDriverWait in combination with
ExpectedCondition is one way this can be accomplished.
This waits up to 10 seconds before throwing a
TimeoutException or if it finds the element will return it in 0 - 10 seconds.
WebDriverWait by default calls the ExpectedCondition every 500 milliseconds
until it returns successfully. A successful return is for ExpectedCondition
type is Boolean return true or not null return value for all other
ExpectedCondition types.
This example is also functionally equivalent
to the first Implicit Waits example.
Expected
Conditions
There are some common conditions that are
frequently come across when automating web browsers. Listed below are
Implementations of each. Java happens to have convienence methods so you don’t
have to code an ExpectedCondition class yourself or create your own utility
package for them.
Element is Clickable - it is
Displayed and Enabled.
The ExpectedConditions package (Java) (Python) (.NET) contains a set of predefined conditions to use with
WebDriverWait.
Implicit
Waits
An implicit wait is to tell WebDriver to poll
the DOM for a certain amount of time when trying to find an element or elements
if they are not immediately available. The default setting is 0. Once set, the
implicit wait is set for the life of the WebDriver object instance.
The Actions class(es) allow you to build a
Chain of Actions and perform them. There are too many possible combinations to
count. Below are a few of the common interactions that you may want to use. For
a full list of actions please refer to the API docs JavaC#RubyPython
The Advanced User Interactions require native
events to be enabled. Here’s a table of the current support Matrix for native
events:
The easiest and recommended way is to
manually set the proxy on the machine that will be running the test. If that is
not possible or you want your test to run with a different configuration or
proxy, then you can use the following technique that uses a Capababilities
object. This temporarily changes the system’s proxy settings and changes them
back to the original state when done.
Is basically the same as internet explorer.
It uses the same configuration on the machine as IE does (on windows). On Mac
it uses the System Preference -> Network settings. On Linux it uses (on
Ubuntu) System > Preferences > Network Proxy Preferences (Alternatively
in “/etc/environment” set http_proxy). As of this writing it is unknown how to
set the proxy programmatically.
Firefox
Firefox maintains it’s proxy configuration in
a profile. You can preset the proxy in a profile and use that Firefox Profile
or you can set it on profile that is created on the fly as is shown in the
following example.