SlideShare a Scribd company logo
Automation Tests with
Selenium
© By Tzirla Rozental
Agenda:
What is QA Automation?
What and How to Automate?
Create Project
Code Planning & Design
Selenium selectors
Run test
Failures
What is QA Automation
Tests?
Software executes and replaces tasks
that done manually
Automates tasks that are impossible to
do manually
What and How to
Automate?
2. What is the interface that needs to be
tested? (CLI, API, GUI ?)
How to pick the right tool?
 Ease of Use
 Tool availability
 Support all kinds of tests you need
 Able to create Automated Tests Without Programming
 Automated Test Scripting
 More: compare results, logging, exporting, support
multi kinds of environments etc.
Features TestComplete Selenium UFT
Record and
Playback
Yes Limited Yes
Scripting
Languages
Python, VBScript,
JScript, C++, C#, and
Delphi
Java, C#, Ruby,
Python, Perl, PHP ,
Javascript
VBScript
IDE Integrations
VisualStudio and
RADStudio
Intellij, Eclipse,
Visual Studio
None
Unit Testing
Support
PyUnit, Ruby, PHPUnit,
JUnit, NUnit, and
TestNG
Java, C#, Ruby,
Python,Perl, PHP ,
Javascript
VBScript
BDD/TDD Support Yes Manual None
Data-Driven
Testing
Yes Manual Yes
Source Control
Management
Git, Subversion, Visual
SourceSafe, CVS, Team
Coherence
Manual Git and Subversion
Writing the web
Automation tests
with
Selenium Web Driver
Install and Create the Project:
1. Install java
2. Install Eclipse and select Workspace
3. Install Selenium (last version)
http://www.softwaretestinghelp.com/webdriver-eclipse-installation-selenium-
tutorial-9/
4. Install Maven (for Maven project) – From eclipse Marketplace
5. Create a Maven Project
6. Install TestNG and configure to right version – From eclipse Marketplace
7. Download jar for browser (for example: ‘chromedriver.exe’ for running tests on
Chrome)
I
Select the Workspace:
Create maven project
From Top menu select File -
>New -> Other
In the pop-up window select Maven
and continue according the steps in
above link:
See full scenario:
http://toolsqa.com/java/maven/create-new-maven-project-eclipse/
Install plugins from Eclipse Marketplace
In top menu select Help ->
Eclipse Marketplace
Search for plugin and install
Code Planning
& Design
Before Starting:
‘test’ package and ‘src’ package
3 Layer model:
Test
BusinessLogic
Page
Common Package – static classes
 General – static arguments
that are sets one a run
 SeleniumActions – include
all selenium selectors
functions
 Utils – manage the
activation of the run
Inheritance in ‘tests’ layer – Actions in
BaseTest – set the logger and driver
 @BeforeClass – set logger and Driver  @AfterClass – stop the driver
Check actions that needed for test
-> TODO
Page Layer
Inheritance in page – BasePage.java
Inheritance in page – child pages classes
extends from the BasePage.java
 HomePage.java  RegistrationPage.java
Finding Elements:
• Using inspect in browser
• Selenium elements locators
• Css and xpath
• findElement() and findElements()
Can see more in:
http://www.slideshare.net/LivePersonDev/selenium-webdriver-element-locators
Inspect in browser
Selenium element locators:
 Id –> driver.findelement(By.id(“id”))
 Name -> driver.findelement(By.name(“name attribute”))
 Tag name -> driver.findelement(By.tagname(“a”))
 LinkText-> driver.findelement(By.linktext(“text_on_link”))
 Css -> driver.findelement(By.cssselector(“#id”))
 xpath -> driver.findelement(By.xpath(“//*[@id=‘id’]”))
 Text -> driver.findelement(By.text(“visible text”))
Css and Xpath
By css – for example:
 Id: “#elementid”
 Class: “.elementclass”
 Otherattribute: “th[style=‘style’]”
 Otherattribute – not specific tag:
“[style=‘style’]”
 Contains: “[class*=‘cl’]”
 Absolute path: “tbody>tr>td”
 Not absolute path: “tbody td”
By xpath – for example:
 “//table[@id=‘tableid’]”
 “//table[@class=‘classname’]”
 “//table[@disabled=‘false’]”
 “//*[@style=‘style’]”
 “//table[contains(@style,’top’)]”
 “//table/tbody/tr/td”
 “tbody//td”
findElement() and findElements()
findElement() findElements()
0
matches
throw exception
(NoSuchElement exception) returns empty list
1 match return the found element returns list with one element
2+
matches
returns only the first one
that found
returns list with all found
elements
Actions on Element
 Selenium Element.Click()
 Element.Clear()
 Element.Sendkeys(text)
 Selenium execute script with java script query:
 jsClick()
 mouseover()
Init page – PageFactory
 @FindBy
(how = How.ID, using = “elementId")
WebElement element
 @FindAll
({@FindBy(how = How.ID, using = “elementId1"),@FindBy(how = How.ID, using =
“elementId2") })
WebElement someElement
Init page syntacs :
Wrong: Page page1 = new Page();
Correct: Page page1 = PageFactory.initElement(WebDriver driver, Page.class);
Business Logic Layer
BusinessLogic layer – Mediator between
the Test and the page
 Processing commands (send to click on element)
 Coordinating workflow (test sent to got message after click on
element)
 Maintaining application state (current data in page)
 Accessing data(from page or other, get data from displayed message)
 Making logical decisions
 Performing calculations
 Page Object – BL layer get and returns an object with data from page
Write the @Test
 Use method created before in page layer and BL
layer
 Write as the steps order in manual test
 Add logs:
Explain what each step is going to check
 Assert – apply the checking
 Leave clean area at the end of the test
@Annotations
 TestNG annotations - @Test, @BeforeMethod,
@AfterMethod etc.
 Java,lang annotations - @Override, @Deprecated
etc.
 Org.openqa.selenium.supportannotations -
@FindBy, @FindAll etc.
Run / Debug Test with TestNG
Run / Debug Configuration:
Select Class and Method Set system property (if needed)
OOPS… Failures
 Check Test Failed
 tackeScreenshot() Method will keep the site
appearance when test failed
 Check Exception
 Check in log
 Failures reasons: automation code issue/
dev changes / bug
Good Luck!

More Related Content

What's hot

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
Naresh Chintalcheru
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
Ana Sarbescu
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Aneesh Rangarajan
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
Return on Intelligence
 
Selenium
SeleniumSelenium
Selenium
Adam Goucher
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
Kerry Buckley
 
Introduction to Selenium Automation
Introduction to Selenium AutomationIntroduction to Selenium Automation
Introduction to Selenium Automation
Mindfire Solutions
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
shreyas JC
 
Introduction to selenium
Introduction to seleniumIntroduction to selenium
Introduction to selenium
Archana Krushnan
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Edureka!
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
Cynoteck Technology Solutions Private Limited
 
Selenium
SeleniumSelenium
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
Praveen Gorantla
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
Vijay Krishnan Ramaswamy
 
Test Automation Using Selenium
Test Automation Using SeleniumTest Automation Using Selenium
Test Automation Using Selenium
Nikhil Kapoor
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
Mindfire Solutions
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
Simplilearn
 

What's hot (20)

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Selenium
SeleniumSelenium
Selenium
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Introduction to Selenium Automation
Introduction to Selenium AutomationIntroduction to Selenium Automation
Introduction to Selenium Automation
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Introduction to selenium
Introduction to seleniumIntroduction to selenium
Introduction to selenium
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Selenium
SeleniumSelenium
Selenium
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
Test Automation Using Selenium
Test Automation Using SeleniumTest Automation Using Selenium
Test Automation Using Selenium
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
 

Similar to Automation - web testing with selenium

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
SpringPeople
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
David Noble
 
Testing In Java4278
Testing In Java4278Testing In Java4278
Testing In Java4278
contact.bsingh
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
Quontra Solutions
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Selenium
SeleniumSelenium
Selenium
Sun Technlogies
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hell
Nikita Simonovets
 
Selenium Testing Training in Bangalore
Selenium Testing Training in BangaloreSelenium Testing Training in Bangalore
Selenium Testing Training in Bangalore
rajkamal560066
 
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QAFest
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presentedVijayan Reddy
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
Ajit Jadhav
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
Artem Nagornyi
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Nalin Goonawardana
 
Introduction to Selenium and Test Automation
Introduction to Selenium and Test AutomationIntroduction to Selenium and Test Automation
Introduction to Selenium and Test Automation
Ahmed Mubbashir Khan
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnetVlad Maniak
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
pleeps
 
Selenium training
Selenium trainingSelenium training
Selenium training
Suresh Arora
 
Qa process
Qa processQa process
Qa process
Aila Bogasieru
 

Similar to Automation - web testing with selenium (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
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Testing In Java4278
Testing In Java4278Testing In Java4278
Testing In Java4278
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Selenium
SeleniumSelenium
Selenium
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hell
 
Selenium Testing Training in Bangalore
Selenium Testing Training in BangaloreSelenium Testing Training in Bangalore
Selenium Testing Training in Bangalore
 
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Introduction to Selenium and Test Automation
Introduction to Selenium and Test AutomationIntroduction to Selenium and Test Automation
Introduction to Selenium and Test Automation
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
Qa process
Qa processQa process
Qa process
 

Recently uploaded

Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 

Recently uploaded (13)

Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 

Automation - web testing with selenium

  • 2. Agenda: What is QA Automation? What and How to Automate? Create Project Code Planning & Design Selenium selectors Run test Failures
  • 3. What is QA Automation Tests? Software executes and replaces tasks that done manually Automates tasks that are impossible to do manually
  • 4. What and How to Automate?
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. 2. What is the interface that needs to be tested? (CLI, API, GUI ?)
  • 12.
  • 13.
  • 14. How to pick the right tool?  Ease of Use  Tool availability  Support all kinds of tests you need  Able to create Automated Tests Without Programming  Automated Test Scripting  More: compare results, logging, exporting, support multi kinds of environments etc.
  • 15. Features TestComplete Selenium UFT Record and Playback Yes Limited Yes Scripting Languages Python, VBScript, JScript, C++, C#, and Delphi Java, C#, Ruby, Python, Perl, PHP , Javascript VBScript IDE Integrations VisualStudio and RADStudio Intellij, Eclipse, Visual Studio None Unit Testing Support PyUnit, Ruby, PHPUnit, JUnit, NUnit, and TestNG Java, C#, Ruby, Python,Perl, PHP , Javascript VBScript BDD/TDD Support Yes Manual None Data-Driven Testing Yes Manual Yes Source Control Management Git, Subversion, Visual SourceSafe, CVS, Team Coherence Manual Git and Subversion
  • 16. Writing the web Automation tests with Selenium Web Driver
  • 17. Install and Create the Project: 1. Install java 2. Install Eclipse and select Workspace 3. Install Selenium (last version) http://www.softwaretestinghelp.com/webdriver-eclipse-installation-selenium- tutorial-9/ 4. Install Maven (for Maven project) – From eclipse Marketplace 5. Create a Maven Project 6. Install TestNG and configure to right version – From eclipse Marketplace 7. Download jar for browser (for example: ‘chromedriver.exe’ for running tests on Chrome) I
  • 19. Create maven project From Top menu select File - >New -> Other In the pop-up window select Maven and continue according the steps in above link: See full scenario: http://toolsqa.com/java/maven/create-new-maven-project-eclipse/
  • 20. Install plugins from Eclipse Marketplace In top menu select Help -> Eclipse Marketplace Search for plugin and install
  • 22. Before Starting: ‘test’ package and ‘src’ package
  • 24. Common Package – static classes  General – static arguments that are sets one a run  SeleniumActions – include all selenium selectors functions  Utils – manage the activation of the run
  • 25. Inheritance in ‘tests’ layer – Actions in BaseTest – set the logger and driver  @BeforeClass – set logger and Driver  @AfterClass – stop the driver
  • 26. Check actions that needed for test -> TODO
  • 28. Inheritance in page – BasePage.java
  • 29. Inheritance in page – child pages classes extends from the BasePage.java  HomePage.java  RegistrationPage.java
  • 30. Finding Elements: • Using inspect in browser • Selenium elements locators • Css and xpath • findElement() and findElements() Can see more in: http://www.slideshare.net/LivePersonDev/selenium-webdriver-element-locators
  • 32. Selenium element locators:  Id –> driver.findelement(By.id(“id”))  Name -> driver.findelement(By.name(“name attribute”))  Tag name -> driver.findelement(By.tagname(“a”))  LinkText-> driver.findelement(By.linktext(“text_on_link”))  Css -> driver.findelement(By.cssselector(“#id”))  xpath -> driver.findelement(By.xpath(“//*[@id=‘id’]”))  Text -> driver.findelement(By.text(“visible text”))
  • 33. Css and Xpath By css – for example:  Id: “#elementid”  Class: “.elementclass”  Otherattribute: “th[style=‘style’]”  Otherattribute – not specific tag: “[style=‘style’]”  Contains: “[class*=‘cl’]”  Absolute path: “tbody>tr>td”  Not absolute path: “tbody td” By xpath – for example:  “//table[@id=‘tableid’]”  “//table[@class=‘classname’]”  “//table[@disabled=‘false’]”  “//*[@style=‘style’]”  “//table[contains(@style,’top’)]”  “//table/tbody/tr/td”  “tbody//td”
  • 34. findElement() and findElements() findElement() findElements() 0 matches throw exception (NoSuchElement exception) returns empty list 1 match return the found element returns list with one element 2+ matches returns only the first one that found returns list with all found elements
  • 35. Actions on Element  Selenium Element.Click()  Element.Clear()  Element.Sendkeys(text)  Selenium execute script with java script query:  jsClick()  mouseover()
  • 36. Init page – PageFactory  @FindBy (how = How.ID, using = “elementId") WebElement element  @FindAll ({@FindBy(how = How.ID, using = “elementId1"),@FindBy(how = How.ID, using = “elementId2") }) WebElement someElement Init page syntacs : Wrong: Page page1 = new Page(); Correct: Page page1 = PageFactory.initElement(WebDriver driver, Page.class);
  • 38. BusinessLogic layer – Mediator between the Test and the page  Processing commands (send to click on element)  Coordinating workflow (test sent to got message after click on element)  Maintaining application state (current data in page)  Accessing data(from page or other, get data from displayed message)  Making logical decisions  Performing calculations  Page Object – BL layer get and returns an object with data from page
  • 39. Write the @Test  Use method created before in page layer and BL layer  Write as the steps order in manual test  Add logs: Explain what each step is going to check  Assert – apply the checking  Leave clean area at the end of the test
  • 40. @Annotations  TestNG annotations - @Test, @BeforeMethod, @AfterMethod etc.  Java,lang annotations - @Override, @Deprecated etc.  Org.openqa.selenium.supportannotations - @FindBy, @FindAll etc.
  • 41. Run / Debug Test with TestNG
  • 42. Run / Debug Configuration: Select Class and Method Set system property (if needed)
  • 43. OOPS… Failures  Check Test Failed  tackeScreenshot() Method will keep the site appearance when test failed  Check Exception  Check in log  Failures reasons: automation code issue/ dev changes / bug