Advanced Selenium Autoamtion Real Time Support
Advanced Selenium Autoamtion Real Time Support
Advanced Selenium Autoamtion Real Time Support
Selenium
Java
JavaScript
HTML
CSS
Ant
XML
Locators
Java Concepts
Java is:
oplatform independent programming language
osimilar to C++ in syntax
osimilar to Smalltalk in mental paradigm
Pros: also ubiquitous to net
Cons: interpreted, and still under
development (moving target)
Java Features
Java has some interesting features:
oautomatic type checking,
oautomatic garbage collection,
osimplifies pointers; no directly accessible
pointer to memory,
osimplified network access,
omulti-threading!
Java Security
Pointer denial - reduces chances of
virulent programs corrupting host,
Applets even more restricted -
oMay not
run local executables,
Read or write to local file system,
Communicate with any server other than the
originating server.
How it works…!
Compile-time Compile-time Environment
Environment
Class
Loader Java
Class
Bytecode Libraries
Java Verifier
Source
(.java)
Just in
Java Java
Time
Bytecodes Interpreter Java
Compiler
move locally Virtual
or through machine
Java network
Compiler
Runtime System
<form>
<input type="button"
Value="Press"
onClick="window.alert('Hello')
;">
</form>
Selenium Introduction
Not at all object Less Object orinted API Purely Object oriented
oriented API
Cannot move mouse Cannot move mouse Can move mouse cursor
with it with it
Full xpaths have to be Full xpaths have to be No need to append
appended with appended with 'xapth=\\' 'xpath=\\'
'xapth=\\' syntax syntax
Object Identification
To identify the objects such as Links, Buttons, Edit
boxes, Drop downs, etc on the application Selenium
uses a concept called “Locators”.
There are around 8 different types of locators.
Out of them, explaining only four as they are widely
used while automating the test cases using Selenium.
Should write
Do
programmers
few
Why?
I am so busy
It is difficult
45
TestNG
Automated testing framework
NG = Next Generation
Similar to JUnit (especially JUnit 4)
Not a JUnit extension (but inspired by JUnit)
Designed to be better than JUnit, especially
when testing integrated classes
Created by Dr. Cédric Beust (of Google)
Open source (http://testng.org)
Locators
Element Locators
ID: id=foo
Name: name=foo
First ID, then name: identifier=foo
DOM: document.forms[‘myform’].myDropdown
XPath: xpath=//table[@id='table1']//tr[4]/td[2]
Link Text: link=sometext
CSS Selector: css=a[href=“#id3”]
Sensible defaults, e.g. xpath if starts with //
selenium.click("btnG");
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, ie.
filterType=argument Supported element-
filters are:
value=value Pattern
Matches elements based on their values.
This is particularly useful for refining a list
of similarly-named toggle-buttons .
index=index
String-match Patterns
Various Pattern syntaxes are available for matching string
values:
glob: pattern: Match a string against a "glob" (aka
"wildmat") pattern. "Glob" is a kind of limited regular-
expression syntax typically used in command-line shells. In
a glob pattern, "*" represents any sequence of characters,
and "?" represents any single character. Glob patterns
match against the entire string.
regexp: regexp: Match a string using a regular-
expression. The full power of JavaScript regular-
expressions is available.
exact: string: Match a string exactly, verbatim, without
any of that fancy wildcard stuff.
If no pattern prefix is specified, Selenium assumes that it's
a "glob" pattern.
Selenium-Maven
If you're using Maven, you will find all
Selenium Maven artifacts directly in the
central Maven repository
here: http://repo1.maven.org/maven2/org/
seleniumhq/selenium/
In order to start using Default
Selenium or one of the new Web
Driver implementations in your Maven
project, just add the following dependency
to your pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</gro
Overview of Selenium Maven artifacts
Selenium using Mobiles
Types of Mobile Testing
Emulator
Real device(tethered to workstation)
Real device in a real location on a real network
Selenium Automation for Android &
IOS
The Android Driver uses the RemoteWeb-Driver.
The client side is your test code(Java code).
The server side is an application that gets installed
on the android emulator or device.(android-
server.apk)
The client and the server communicate using the
Wire Protocol which consists of REST requests
JSON and HTTP.
The application executes the tests in the context of
an Android Web View.
UNPACK
~/android_sdk
UPDATE
$ cd~/andriod_sdk/tools
$ ./android update sdk
CREATE AVD
$ ./android create avd \
-n my_android \
-t 8 \
-c 100M
START EMULATOR
$ ./emulator -avd my_android \
-no-audio \
-no-boot- anim \
-scale .8 &
INSTALL SELENIUM APK
$ cd~/android_sdk/platform-tools/
$ ./adb -e install \
-r ~/selenium/android/prebuilt/android-
server.apk
PORT FORWARDING
$ ./adb forward tcp:8080 tcp:8080
LAUNCH APP
$ adb –s shell am start –n\
org.openga.selenium.android.app/
org.openga.selenium.android.app.Mainactivity
Sample Codings of Selenium
driver. get("http://www.google.com"); To open an application
driver.findElement(By. Xpath("//input[@id=’passwd-
id’]")); Finding Element using Xpath
Web: www.thecreatingexperts.com
Powered By