Complete Selenium Bootcamp: Introduction To Selenium Web Driver

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

1

4/22/17
Salhi Houssem
Complete Selenium
Bootcamp
INTRODUCTION TO SELENIUM WEB DRIVER
2
Course OverView

Salhi Houssem 4/22/17


3
Plan

What is selenium 2.0 ?


Architecture of selenium 2.0
Selenium 2.0 API :
Finding elemnts
Basic operation on elemnts
Moving between windows and frames
Waits in Selenium
Preparing environment to use Selenium

Salhi Houssem 4/22/17


4
What is selenium?

Selenium is a set of tools for cross-plateform automated testing of web


applications
Selenium supports :
IE, Firefox, Safari, Opera, Chrome and other browsers
Windows, OS X, Linux, Solaris and other OSs
C#, Java, Perl, PHP, Python, Ruby and other languages
Bromine, Junit, Nunit, Rspec, TestNG, unittest

Salhi Houssem 4/22/17


5
Componnets of selenium

Selenium IDE : is the tool you use to develop your Selenium test cases. Its an easy-
to-use Firefox plug-in and is generally the most efficient way to develop test cases.
Selenium Remote Control (RC) : is a test tool that allows you to write automated
web application UI tests in any programming language against any HTTP website
using any mainstream JavaScript-enabled browser.
Selenium Grid : Selenium-Grid allows you run your tests on different machines
against different browsers in parallel. That is, running multiple tests at the same
time against different machines running different browsers and operating systems.
Selenium 2.0 and WebDriver : WebDriver is the replacement of Selenium RC
Selenium 1.0 (IDE) + RC = Selenium 2.0

Salhi Houssem 4/22/17


6
What is Selenium 2.0

Salhi Houssem 4/22/17


7
Selenium 1.0 Architecture

Salhi Houssem 4/22/17


8
Selenium 2.0 Archaitecture

Salhi Houssem 4/22/17


9
Selenium 2.0 Archaitecture

Salhi Houssem 4/22/17


10
Advantages of Selenium 2.0

1. Selenium is pure open source, freeware and portable tool.


2. Selenium supports variety of languages that include Java, Perl, Python, C#, Ruby, Groovy,
Java Script, and VB Script. etc.
3. Selenium supports many operating systems like Windows, Macintosh, Linux, Unix etc.
4. Selenium supports many browsers like Internet explorer, Chrome, Firefox, Opera, Safari etc.
5. Selenium can be integrated with ANT or Maven kind of framework for source code
compilation.
6. Selenium can be integrated with TestNG testing framework for testing our applications and
generating reports.

Salhi Houssem 4/22/17


11
Advantages of Selenium 2.0

7. Selenium can be integrated with Jenkins or Hudson for continuous


integration.
8. Selenium can be integrated with other open source tools for supporting other
features.
9. Selenium can be used for Android, IPhone, Blackberry etc. based application
testing.
10. Selenium supports very less CPU and RAM consumption for script execution.
11. Selenium comes with different component to provide support to its parent
which is Selenium IDE, Selenium Grid and Selenium Remote Control (RC).

Salhi Houssem 4/22/17


12
Disadvantages of Selenium 2.0

1. Selenium needs very much expertise resources. The resource should also be very well versed
in framework architecture.
2. Selenium only supports web based application and does not support windows based
application.
3. It is difficult to test Image based application.
4. Selenium need outside support for report generation activity like dependence on TestNG or
Jenkins.
5. Selenium does not support built in add-ins support.
6. Selenium user lacks online support for the problems they face.

Salhi Houssem 4/22/17


13
Disadvantages of Selenium 2.0

7. Selenium does not provide any built in IDE for script generation and it need
other IDE like Eclipse for writing scripts.
8. Selenium Automation Engineers are bit in scarcity these days.
9. Selenium script creation time is bit high.
10. Selenium does not support file upload facility.
11. Selenium partially supports for Dialog boxes.

Salhi Houssem 4/22/17


14
WebDriverss Driver

WebDriver :
Fiefox Driver
IE Driver
Chrome Driver
Opera Driver
iPhone Driver
Android Driver

Salhi Houssem 4/22/17


15
Selenium API

WebDriver to control the browser

browser = webdriver.Firefox()

find_element to work with the elements on the page

elem = browser.find_element_by_name(selector)

Salhi Houssem 4/22/17


16
WebDriver API

browser.get(url) open page


Quit() Quits the driver and close every associated window.
driver.switch_to.frame() switching between frames, pop-up and windows
find_element_by_ - locate element on a page with a specific locator
Find_elements_by - locate elements on a page with a specific locator

Salhi Houssem 4/22/17


17
Selenium API: find_elements

find_element_by_id
find_element_by_name
find_element_by_xpath
find_element_by_link_text
find_element_by_partial_link_text
find_element_by_tag_name
find_element_by_class_name
find_element_by_css_selector

Salhi Houssem 4/22/17


18
Tools for finding elements

Add-on FireBug Developpment tools in browsers

Salhi Houssem 4/22/17


19
Selenium API : Basic operations on
elements

click() --- Clicks the element.


Submit() --- submits a form
get_property(name) --- Gets the given property of the element.
send_keys(*value) --- Simulates typing into the element.
clear() --- Clears the text if its a text entry element.
get_attribute(name) --- Gets the given attribute or property of the element.
is_displayed() --- Whether the element is visible to a user.

Salhi Houssem 4/22/17


20
Selenium API : Basic operations on
elements

is_enabled() --- Returns whether the element is enabled.


is_selected() --- Returns whether the element is selected.
screenshot(filename) --- Gets the screenshot of the current element.
Size --- The size of the element.
tag_name --- This elements tagName property.

Salhi Houssem 4/22/17


21
Waits in Selenium

Implicit wait :
time to wait to get an element. If it is used then thie WebDriver will wait the
same time before getting each elemt
Explicit wait :
set a timer for a specific element (not for all elements)
Fluent wait :
WebDriver attempts to find element again and again until it find it or until the final
timer runs out.

Salhi Houssem 4/22/17


22

Setup your
environment

Salhi Houssem 4/22/17


23
Configure Python

Download script "get-pip.py" from


"https://pip.pypa.io/en/stable/installing
/"
Run Terminal and type " python get-
pip.py"

Salhi Houssem 4/22/17


24
Install Selenium

Run terminal and type


"pip install -U selenium"

Salhi Houssem 4/22/17


25
Configure Selenium

Selenium requires a driver to interface with the chosen browser.

Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloads
Edge: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Firefox: https://github.com/mozilla/geckodriver/releases
Safari: https://webkit.org/blog/6900/webdriver-support-in-safari-10/

Make sure its in your PATH, e. g., place it in /usr/bin or /usr/local/bin

Salhi Houssem 4/22/17


26
Download Atom

Download from
"https://atom.io/"

Salhi Houssem 4/22/17


27
Check Selenium environment

from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://testing.todvachev.com/')

Salhi Houssem 4/22/17

You might also like