SlideShare a Scribd company logo
1 of 42
Automation Testing by Selenium
Web Driver
Why automate testing?
Test automation has specific advantages for improving the
long-term efficiency of a software team’s testing processes.
Test automation supports:
Frequent regression testing
Rapid feedback to developers
Virtually unlimited iterations of test case execution
Support for Agile and extreme development methodologies
Disciplined documentation of test cases
Customized defect reporting
Finding defects missed by manual testing
Automation Test Life Cycle
Selenium History
ThoughtWorks in Chicago, Jason Huggins built the Core mode as
"JavaScriptTestRunner" for the testing of an internal Time and Expenses
application (Python, Plone).
2006 - at Google, Simon Stewart started work on a project he called WebDriver. Google
had long been a heavy user of Selenium, but testers had to work around the
limitations of the product. The WebDriver project began with the aim to
solve the Selenium’ pain-points.
2008 - merging of Selenium and WebDriver. Selenium had massive community and
commercial support, but WebDriver was clearly the tool of the future. The joining of
the two tools provided a common set of features for all users and brought some of
the brightest minds in test automation under one roof.
Shinya Kasatani in Japan became interested in Selenium, he
Wrapped the core code into an IDE module into the Firefox browser
Added the ability to record tests as well as play them back in the same plugin.
This tool, turned out an eye opener in more ways that was originally thought as it is
not bound to the same origin policy.
Selenium Components
Selenium IDE –
Limitations/Drawbacks
 Firefox only
 Can not Specify any condition Statement.
 Can not Specify any Looping Statement.
 Can not take external text data from External
Resources such as XLS,XML or Database.
 Handing Exceptions is not in scope.
Note:- To overcome the limitation of Selenium IDE we go for
Selenium WebDriver.
Selenium WebDriver
What is WebDriver?
 WebDriver is one of the component in selenium.
 WebDriver is module.
Firefox browser  Firefox( )
Chrome browser  Chrome()
Edge  Edge( )
WebDriver is an API (Application Programming
Interface)
Selenium Web Driver
 WebDriver is a tool for automating web
application testing, and in particular to verify that
they work as expected.
 It aims to provide a friendly API that’s easy to
explore and understand, easier to use than the
Selenium-RC (1.0) API, which will help to make your
tests easier to read and maintain.
 It’s not tied to any particular test framework, so it
can be used equally well in a unit testing or from a
plain old “main” method.
Selenium Web Driver –
Browser Support
Selenium-WebDriver supports the following browsers along
with the operating systems these browsers are compatible
with.
 Google Chrome
 Internet Explorer
 Firefox
 Opera 11.5+
 HtmlUnit
 Android – 2.3+ for phones and tablets (devices & emulators)
 iOS 3+ for phones (devices & emulators) and 3.2+ for
tablets (devices & emulators)
Simple Architecture of
WebDriver
WEBDRIVER(i)
Remote Webdriver
Firefox Driver Chrome Driver
Internet Explorer
Driver
Interface
Protected class
WebDriver API
WebDriver API
Architecture of WebDriver
Selenium Language bindings – JSON wire protocol Browser drivers ---W3C--Browser
Architecture of WebDriver
Selenium Language bindings – W3C protocol Browser drivers ---W3C--Browsers
Installing Python bindings for Selenium
Use pip to install the selenium package. Python 3 has pip available in the standard
library. Using pip, you can install selenium like this:
pip install selenium
C:Python39Scriptspip.exe install selenium
C:Python39python.exe C:my_selenium_script.py
Browsers Drivers installation
Chrome:https://sites.google.com/chromium.org/driver/
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
Setup & Configure WebDriver in Pycharm
PyCharm is a cross-platform IDE that provides consistent
experience on the Windows, macOS, and Linux operating
systems.
PyCharm is available in two editions: Professional,
and Community. The Community edition is an open-source
project, and it's free, but it has fewer features.
The Professional edition is commercial, and provides an
outstanding set of tools and features. For details, see the editions
comparison matrix
Setup & Configure WebDriver in Pycharm
Setup & Configure WebDriver in Pycharm
Setup & Configure WebDriver in Pycharm
Setup & Configure WebDriver in Pycharm
Setup & Configure WebDriver in Pycharm
Setup & Configure WebDriver in Pycharm
Setup & Configure WebDriver in Pycharm
Types of Locators
Matching Text Patterns
 Like locators, patterns are a type of parameter
frequently required by Selenese commands.
 Examples of commands which require patterns are
 verifyTextPresent,
 verifyTitle,
 verifyAlert,
 assertConfirmation,
 verifyText, and
 verifyPrompt.
 link locators can utilize a pattern.
 Patterns allow you to describe, via the use of special
characters, what text is expected rather than having to specify
that text exactly.
Write the Selenium test script
Write the Selenium test script
Step1
In the first step, we will type the following statement to import the web driver:
from selenium import webdriver
Step2
After that, we will open the Google Chrome browser.
As we can see in the below screenshot, we have multiple types of browsers options
available, and we can select any browser from the list like Chrome, Edge, firefox,
Internet Explorer, opera, safari, etc.
driver = webdriver.Chrome()
Step3
In the next step, we will be maximizing our browser window size, and the sample code
is as below:
driver.maximize_window()
Write the Selenium test script
Step4
Then, we will navigate to the given URL. The sample code is as below:
driver.get("https://www.google.com/")
Step5
In this step, we are trying to locate the Google search text box with the help of
its Name attribute value.
Right-click on the Google search text box, and select the Inspect option in the pop-up
menu as we can see in the below image:
driver.find_element_by_name("q").send_keys("javatpoint")
Step6
Once we identify the Google search text box, and we will identify the Google Search
button.
So for this, follow the below process:
driver.find_element_by_name("btnK").send_keys(Keys.ENTER)
Step7
In the last step, we are closing the browser.
driver.close()
Write the Selenium test script
from Selenium import webdriver
import time
from Selenium.webdriver.common.keys import Keys
print("sample test case started")
driver = webdriver.Chrome()
#driver=webdriver.firefox()
#driver=webdriver.ie()
#maximize the window size
driver.maximize_window()
#navigate to the url
driver.get("https://www.google.com/")
#identify the Google search text box and enter the value
driver.find_element_by_name("q").send_keys("javatpoint")
time.sleep(3)
#click on the Google search button
driver.find_element_by_name("btnK").send_keys(Keys.ENTER)
time.sleep(3)
#close the browser
driver.close()
print("sample test case successfully completed")
Selenium First Code
Browser open by Webdriver.
Methods:- “findElement” is a method of webdriver interface which is
Use to identify required element in the application. This method takes an
Object as an argument of type “By”.
Locators:- Webdriver supports 8 types of locators to identify the
Elements and all the locators will return the object of the type
Webelements.
Types of Locators:-
1. By.id(arg)
2. By.name(String)
3. By.xpath(String xpathExpression)
4. By.cssSelector(String Selector)
5. By.linkText(String linkText)
6. By.partialLinkText(String linkText)
7. By.className(String className)
8. By.tagName(String Name)
Locator Code:-
Locator Code impact.
Retrieving the value from
application
While doing validation we compare excepted result and actual
result then we will report the status. Actual result will be taken from
application during runtime. In order to do this we use following important
Method.
1. getTitle() :- This method help us to retrieve the title of the webpage.
2.GetcurrentUrl():- This method will retrieve the current url from the
address bar of the browser.
3.getAttribute(“value”) :- This is used to retrieve property value from the
element present in the application. It is basically used to retrieve text from
Textbox, password field, Address Field, Path of uploading file and button
name.
4.isEnable() :- This method is used to check whether the specify elements
enable or not. True indicates enable and false indicates disable.
5.isSelected() :- It is used to checked whether the specific checkbox or radio
button is selected or not.
6. getText():- It is used to retrieve the text of the following element.
Windows Handles
Browser Operations
1. Navigate back to Previous Page:-
driver.navigate().back();
2. Navigate to the next Page:-
driver.navigate().forward();
3. Refresh Mehods :-
driver
.navigate().refresh();
Handling Frames
Selenium Python Quiz for Automation Testing.
1. Question
Which of the following expected conditions tests for an active element?
1. element_located_to_be_selected
2. element_to_be_clickable
3. element_selection_state_to_be3.
4. element_to_be_selected4.
2. Question
If no element has a matching id attribute, a NoSuchElementException will be raised.
True or False?
1. False
2. True2.
3. Question
Which of the following exceptions occurs when an element is present in the DOM but
interactions with that element will hit another element?
1. ImeNotAvailableException
2. ElementNotSelectableException
3. ErrorInResponseException
4. ElementNotVisibleException
5. ElementNotInteractableException
Selenium Python Quiz for Automation Testing.
4. Question
Which of the following functions does return a list of elements?
1. find_element_by_id
2. find_elements_by_name2.
3. find_element_by_xpath
4. find_element_by_link_text
5. find_element_by_partial_link_text5.
5. Question
Which of the following is the recommended style of import?
1. from selenium import *
2. import selenium, webdriver
3. from selenium import webdriver
4. import selenium.webdriver
6. Question
Which of the following functions would only deselect a single option?
1. deselect_by_visible_text(text)
2. deselect_all()
3. None
4. deselect_by_value(value)
5. deselect_by_index(index)
Selenium Python Quiz for Automation Testing.
7. Question
What is the difference between the following methods of the
selenium.webdriver.common.action_chains.ActionChains class?
A) send_keys(*keys_to_send)
B) send_keys_to_element(element, *keys_to_send)
1. None
2. A sends keys to the first visible element whereas B sends keys to the selected element.
3. A sends keys to currently focused element whereas B sends keys to the target element.
4. A sends keys to the first element it finds whereas B sends keys to the target element
8. Question
How to wait until an element is no longer attached to the DOM?
1. None
2. selenium.webdriver.support.expected_conditions.presence_of_all_elements_located(locator)
3. selenium.webdriver.support.expected_conditions.presence_of_element_located(locator)
4. selenium.webdriver.support.expected_conditions.staleness_of(element)
9. Question
Which of the following methods makes an expectation for checking an element is visible and enabled?
1. None
2. selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator)
3. selenium.webdriver.support.expected_conditions.element_to_be_selected(element)
4. selenium.webdriver.support.expected_conditions.element_to_be_clickable(locator)
Selenium Python Quiz for Automation Testing.
7. Question
What is the difference between the following methods of the
selenium.webdriver.common.action_chains.ActionChains class?
A) send_keys(*keys_to_send)
B) send_keys_to_element(element, *keys_to_send)
1. None
2. A sends keys to the first visible element whereas B sends keys to the selected element.
3. A sends keys to currently focused element whereas B sends keys to the target element.
4. A sends keys to the first element it finds whereas B sends keys to the target element
8. Question
How to wait until an element is no longer attached to the DOM?
1. None
2. selenium.webdriver.support.expected_conditions.presence_of_all_elements_located(locator)
3. selenium.webdriver.support.expected_conditions.presence_of_element_located(locator)
4. selenium.webdriver.support.expected_conditions.staleness_of(element)
9. Question
Which of the following methods makes an expectation for checking an element is visible and enabled?
1. None
2. selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator)
3. selenium.webdriver.support.expected_conditions.element_to_be_selected(element)
4. selenium.webdriver.support.expected_conditions.element_to_be_clickable(locator)

More Related Content

Similar to Selenium.pptx

Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Rashedul Islam
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxAnanthReddy38
 
Run Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test ManagerRun Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test ManagerDaniel Herken
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presentedVijayan Reddy
 
Selenium training
Selenium trainingSelenium training
Selenium trainingShivaraj R
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfAnanthReddy38
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionAmr E. Mohamed
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium Zoe Gilbert
 
Executing Parallel Test Sessions with TestNG and Selenium WebDriver
Executing Parallel Test Sessions with TestNG and Selenium WebDriverExecuting Parallel Test Sessions with TestNG and Selenium WebDriver
Executing Parallel Test Sessions with TestNG and Selenium WebDriverpCloudy
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with AppiumLuke Maung
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
 

Similar to Selenium.pptx (20)

Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Qa process
Qa processQa process
Qa process
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
 
Run Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test ManagerRun Selenium Tests With Microsoft Test Manager
Run Selenium Tests With Microsoft Test Manager
 
Qa process
Qa processQa process
Qa process
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 
Selenium
SeleniumSelenium
Selenium
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
jDriver Presentation
jDriver PresentationjDriver Presentation
jDriver Presentation
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Selenium
SeleniumSelenium
Selenium
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
Selenium With Spices
Selenium With SpicesSelenium With Spices
Selenium With Spices
 
Selenium
SeleniumSelenium
Selenium
 
Executing Parallel Test Sessions with TestNG and Selenium WebDriver
Executing Parallel Test Sessions with TestNG and Selenium WebDriverExecuting Parallel Test Sessions with TestNG and Selenium WebDriver
Executing Parallel Test Sessions with TestNG and Selenium WebDriver
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 

More from Pandiya Rajan

More from Pandiya Rajan (20)

CICD.pptx
CICD.pptxCICD.pptx
CICD.pptx
 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
 
css1.pptx
css1.pptxcss1.pptx
css1.pptx
 
HTML-Basic.pptx
HTML-Basic.pptxHTML-Basic.pptx
HTML-Basic.pptx
 
UNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptxUNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptx
 
UNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptxUNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptx
 
UNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptxUNIT-I Introduction to CICD.pptx
UNIT-I Introduction to CICD.pptx
 
page_fault pbm.ppt
page_fault pbm.pptpage_fault pbm.ppt
page_fault pbm.ppt
 
process syn.ppt
process syn.pptprocess syn.ppt
process syn.ppt
 
selinuxbasicusage.pptx
selinuxbasicusage.pptxselinuxbasicusage.pptx
selinuxbasicusage.pptx
 
lvm.pptx
lvm.pptxlvm.pptx
lvm.pptx
 
SSH.ppt
SSH.pptSSH.ppt
SSH.ppt
 
environmentalpollution-.pptx
environmentalpollution-.pptxenvironmentalpollution-.pptx
environmentalpollution-.pptx
 
DM.pptx
DM.pptxDM.pptx
DM.pptx
 
thermal pollution.pptx
thermal pollution.pptxthermal pollution.pptx
thermal pollution.pptx
 
marinepollution.pptx
marinepollution.pptxmarinepollution.pptx
marinepollution.pptx
 
logical volume manager.ppt
logical volume manager.pptlogical volume manager.ppt
logical volume manager.ppt
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
c-c++-java-python programs.docx
c-c++-java-python programs.docxc-c++-java-python programs.docx
c-c++-java-python programs.docx
 
CMMI.pptx
CMMI.pptxCMMI.pptx
CMMI.pptx
 

Recently uploaded

Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 

Recently uploaded (20)

Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 

Selenium.pptx

  • 1. Automation Testing by Selenium Web Driver
  • 2. Why automate testing? Test automation has specific advantages for improving the long-term efficiency of a software team’s testing processes. Test automation supports: Frequent regression testing Rapid feedback to developers Virtually unlimited iterations of test case execution Support for Agile and extreme development methodologies Disciplined documentation of test cases Customized defect reporting Finding defects missed by manual testing
  • 4. Selenium History ThoughtWorks in Chicago, Jason Huggins built the Core mode as "JavaScriptTestRunner" for the testing of an internal Time and Expenses application (Python, Plone). 2006 - at Google, Simon Stewart started work on a project he called WebDriver. Google had long been a heavy user of Selenium, but testers had to work around the limitations of the product. The WebDriver project began with the aim to solve the Selenium’ pain-points. 2008 - merging of Selenium and WebDriver. Selenium had massive community and commercial support, but WebDriver was clearly the tool of the future. The joining of the two tools provided a common set of features for all users and brought some of the brightest minds in test automation under one roof. Shinya Kasatani in Japan became interested in Selenium, he Wrapped the core code into an IDE module into the Firefox browser Added the ability to record tests as well as play them back in the same plugin. This tool, turned out an eye opener in more ways that was originally thought as it is not bound to the same origin policy.
  • 6. Selenium IDE – Limitations/Drawbacks  Firefox only  Can not Specify any condition Statement.  Can not Specify any Looping Statement.  Can not take external text data from External Resources such as XLS,XML or Database.  Handing Exceptions is not in scope. Note:- To overcome the limitation of Selenium IDE we go for Selenium WebDriver.
  • 7. Selenium WebDriver What is WebDriver?  WebDriver is one of the component in selenium.  WebDriver is module. Firefox browser  Firefox( ) Chrome browser  Chrome() Edge  Edge( ) WebDriver is an API (Application Programming Interface)
  • 8. Selenium Web Driver  WebDriver is a tool for automating web application testing, and in particular to verify that they work as expected.  It aims to provide a friendly API that’s easy to explore and understand, easier to use than the Selenium-RC (1.0) API, which will help to make your tests easier to read and maintain.  It’s not tied to any particular test framework, so it can be used equally well in a unit testing or from a plain old “main” method.
  • 9. Selenium Web Driver – Browser Support Selenium-WebDriver supports the following browsers along with the operating systems these browsers are compatible with.  Google Chrome  Internet Explorer  Firefox  Opera 11.5+  HtmlUnit  Android – 2.3+ for phones and tablets (devices & emulators)  iOS 3+ for phones (devices & emulators) and 3.2+ for tablets (devices & emulators)
  • 10. Simple Architecture of WebDriver WEBDRIVER(i) Remote Webdriver Firefox Driver Chrome Driver Internet Explorer Driver Interface Protected class
  • 13. Architecture of WebDriver Selenium Language bindings – JSON wire protocol Browser drivers ---W3C--Browser
  • 14. Architecture of WebDriver Selenium Language bindings – W3C protocol Browser drivers ---W3C--Browsers
  • 15. Installing Python bindings for Selenium Use pip to install the selenium package. Python 3 has pip available in the standard library. Using pip, you can install selenium like this: pip install selenium C:Python39Scriptspip.exe install selenium C:Python39python.exe C:my_selenium_script.py
  • 17. Setup & Configure WebDriver in Pycharm PyCharm is a cross-platform IDE that provides consistent experience on the Windows, macOS, and Linux operating systems. PyCharm is available in two editions: Professional, and Community. The Community edition is an open-source project, and it's free, but it has fewer features. The Professional edition is commercial, and provides an outstanding set of tools and features. For details, see the editions comparison matrix
  • 18. Setup & Configure WebDriver in Pycharm
  • 19. Setup & Configure WebDriver in Pycharm
  • 20. Setup & Configure WebDriver in Pycharm
  • 21. Setup & Configure WebDriver in Pycharm
  • 22. Setup & Configure WebDriver in Pycharm
  • 23. Setup & Configure WebDriver in Pycharm
  • 24. Setup & Configure WebDriver in Pycharm
  • 26. Matching Text Patterns  Like locators, patterns are a type of parameter frequently required by Selenese commands.  Examples of commands which require patterns are  verifyTextPresent,  verifyTitle,  verifyAlert,  assertConfirmation,  verifyText, and  verifyPrompt.  link locators can utilize a pattern.  Patterns allow you to describe, via the use of special characters, what text is expected rather than having to specify that text exactly.
  • 27. Write the Selenium test script
  • 28. Write the Selenium test script Step1 In the first step, we will type the following statement to import the web driver: from selenium import webdriver Step2 After that, we will open the Google Chrome browser. As we can see in the below screenshot, we have multiple types of browsers options available, and we can select any browser from the list like Chrome, Edge, firefox, Internet Explorer, opera, safari, etc. driver = webdriver.Chrome() Step3 In the next step, we will be maximizing our browser window size, and the sample code is as below: driver.maximize_window()
  • 29. Write the Selenium test script Step4 Then, we will navigate to the given URL. The sample code is as below: driver.get("https://www.google.com/") Step5 In this step, we are trying to locate the Google search text box with the help of its Name attribute value. Right-click on the Google search text box, and select the Inspect option in the pop-up menu as we can see in the below image: driver.find_element_by_name("q").send_keys("javatpoint") Step6 Once we identify the Google search text box, and we will identify the Google Search button. So for this, follow the below process: driver.find_element_by_name("btnK").send_keys(Keys.ENTER) Step7 In the last step, we are closing the browser. driver.close()
  • 30. Write the Selenium test script from Selenium import webdriver import time from Selenium.webdriver.common.keys import Keys print("sample test case started") driver = webdriver.Chrome() #driver=webdriver.firefox() #driver=webdriver.ie() #maximize the window size driver.maximize_window() #navigate to the url driver.get("https://www.google.com/") #identify the Google search text box and enter the value driver.find_element_by_name("q").send_keys("javatpoint") time.sleep(3) #click on the Google search button driver.find_element_by_name("btnK").send_keys(Keys.ENTER) time.sleep(3) #close the browser driver.close() print("sample test case successfully completed")
  • 32. Browser open by Webdriver.
  • 33. Methods:- “findElement” is a method of webdriver interface which is Use to identify required element in the application. This method takes an Object as an argument of type “By”. Locators:- Webdriver supports 8 types of locators to identify the Elements and all the locators will return the object of the type Webelements. Types of Locators:- 1. By.id(arg) 2. By.name(String) 3. By.xpath(String xpathExpression) 4. By.cssSelector(String Selector) 5. By.linkText(String linkText) 6. By.partialLinkText(String linkText) 7. By.className(String className) 8. By.tagName(String Name)
  • 36. Retrieving the value from application While doing validation we compare excepted result and actual result then we will report the status. Actual result will be taken from application during runtime. In order to do this we use following important Method. 1. getTitle() :- This method help us to retrieve the title of the webpage. 2.GetcurrentUrl():- This method will retrieve the current url from the address bar of the browser. 3.getAttribute(“value”) :- This is used to retrieve property value from the element present in the application. It is basically used to retrieve text from Textbox, password field, Address Field, Path of uploading file and button name. 4.isEnable() :- This method is used to check whether the specify elements enable or not. True indicates enable and false indicates disable. 5.isSelected() :- It is used to checked whether the specific checkbox or radio button is selected or not. 6. getText():- It is used to retrieve the text of the following element.
  • 38. Browser Operations 1. Navigate back to Previous Page:- driver.navigate().back(); 2. Navigate to the next Page:- driver.navigate().forward(); 3. Refresh Mehods :- driver .navigate().refresh(); Handling Frames
  • 39. Selenium Python Quiz for Automation Testing. 1. Question Which of the following expected conditions tests for an active element? 1. element_located_to_be_selected 2. element_to_be_clickable 3. element_selection_state_to_be3. 4. element_to_be_selected4. 2. Question If no element has a matching id attribute, a NoSuchElementException will be raised. True or False? 1. False 2. True2. 3. Question Which of the following exceptions occurs when an element is present in the DOM but interactions with that element will hit another element? 1. ImeNotAvailableException 2. ElementNotSelectableException 3. ErrorInResponseException 4. ElementNotVisibleException 5. ElementNotInteractableException
  • 40. Selenium Python Quiz for Automation Testing. 4. Question Which of the following functions does return a list of elements? 1. find_element_by_id 2. find_elements_by_name2. 3. find_element_by_xpath 4. find_element_by_link_text 5. find_element_by_partial_link_text5. 5. Question Which of the following is the recommended style of import? 1. from selenium import * 2. import selenium, webdriver 3. from selenium import webdriver 4. import selenium.webdriver 6. Question Which of the following functions would only deselect a single option? 1. deselect_by_visible_text(text) 2. deselect_all() 3. None 4. deselect_by_value(value) 5. deselect_by_index(index)
  • 41. Selenium Python Quiz for Automation Testing. 7. Question What is the difference between the following methods of the selenium.webdriver.common.action_chains.ActionChains class? A) send_keys(*keys_to_send) B) send_keys_to_element(element, *keys_to_send) 1. None 2. A sends keys to the first visible element whereas B sends keys to the selected element. 3. A sends keys to currently focused element whereas B sends keys to the target element. 4. A sends keys to the first element it finds whereas B sends keys to the target element 8. Question How to wait until an element is no longer attached to the DOM? 1. None 2. selenium.webdriver.support.expected_conditions.presence_of_all_elements_located(locator) 3. selenium.webdriver.support.expected_conditions.presence_of_element_located(locator) 4. selenium.webdriver.support.expected_conditions.staleness_of(element) 9. Question Which of the following methods makes an expectation for checking an element is visible and enabled? 1. None 2. selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator) 3. selenium.webdriver.support.expected_conditions.element_to_be_selected(element) 4. selenium.webdriver.support.expected_conditions.element_to_be_clickable(locator)
  • 42. Selenium Python Quiz for Automation Testing. 7. Question What is the difference between the following methods of the selenium.webdriver.common.action_chains.ActionChains class? A) send_keys(*keys_to_send) B) send_keys_to_element(element, *keys_to_send) 1. None 2. A sends keys to the first visible element whereas B sends keys to the selected element. 3. A sends keys to currently focused element whereas B sends keys to the target element. 4. A sends keys to the first element it finds whereas B sends keys to the target element 8. Question How to wait until an element is no longer attached to the DOM? 1. None 2. selenium.webdriver.support.expected_conditions.presence_of_all_elements_located(locator) 3. selenium.webdriver.support.expected_conditions.presence_of_element_located(locator) 4. selenium.webdriver.support.expected_conditions.staleness_of(element) 9. Question Which of the following methods makes an expectation for checking an element is visible and enabled? 1. None 2. selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator) 3. selenium.webdriver.support.expected_conditions.element_to_be_selected(element) 4. selenium.webdriver.support.expected_conditions.element_to_be_clickable(locator)