SlideShare a Scribd company logo
SELENIUM
Automation Testing
Introduction to Selenium
Who named Automation testing tool as Selenium?
● Jason Huggins and team from ThoughtWorks Inc. developed the testing tool
in 2004.
● Huggins joked about competitor HP mercury tools saying it cures mercury
poisoning by taking Selenium supplements.
● Hence, the name!
How to start - Windows 7, 8 and XP
Webdriver-To control Browser
webDriver driver=new FirefoxDriver();
WebElement-to work with the elements of the page=
WebElement element=driver.findelement(By.id(“id”));
Methods:- “findElement” is a method in webdriver interface which is used to identify required element in the
application.This method takes as an object as an argument of type “By”.
Locators:-Webdriver supports 8 locators to identify the element.
Types of Locators:- 1.By.id(arg)
2.By.name(string)
3.By.xpath(String xpath expression)
4.By.cssSelector(String selector)
5.By.tagName(String name)
6.By.linkText(string linkText)
7.By.partiallinkText(string linkText)
8.By.className(String className)
What is Xpath ?
Xpath=//tagname[@attribute=’value’]
How to execute Automation Testing using Selenium
Select Class
Types :- 1.SelectByVisibletext()
2.SelectByIndex()
3.SelectbyValue()
4.deselectAll()
5.isMultiple()
6.getOption()
7.getFirstSelectedOption()
8.getAllSelectedOption()
Waits
Types:- 1.Normal Wait
thread.sleep(20,000)
2.implicitly wait
driver.manage().timeouts().implicitlywait(10,TimeUnit.SECONDS)
3.Explicitly wait
WebdriverWait=new WebDriverWait(driver.20)
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath( "String Xpath
Expression")));
Action Class
Action class used to perform user interaction operation like mousehover, right-click , double click & keyboard
operation.
Step-1 : Find a element where we need to perform mouseover operation.
WebElement wb = driver.findelement(By.xpath(“….”));
Step-2: Create an object to Action class.
Actions act = new Actions(driver);
Step-3: Use Mouse over operation :
act.moveToelement(wb).perform();
Window Handling
Step-1: Click the button which opens child window.
WebElement wb = driver.findelement(By.xpath(“….”));
Step-2: Get all the current active window Id’s.
Set<String> set = driver.getWindowHandles();
Step-3: Using iterator capture the Window Id’s from SET
Iterator<String> itr = set.iterator();
String ParentID = itr.next();
String ChildID=itr.next();
Step-4: Pass driver control to child window.
driver.switchTo().window(childID);
Screenshots
Step-1: EventFiringWebDriver dDriver = new EventFiringWebDriver(driver);
Step-2: getScreenshotAs() method returns imagefile.
File SrcImg = dDriver.getScreenshotAs(OutputType.File)
File dstnImag = new File(“c:userscreenshottest.png”)
Step-3: Get a help Apache poi, to store image in loca system.
FileUtils.copyFile(srcImg , dstimg)
How To DownLoad a file from a Browser
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk"Mime type of the file”);
How To Upload a file in a Browser
First we need to install AutoIt
WinActive(“$”)
fileupload(give the path of the file you want to upload)
ControlSetText(fileupload.$,edit1)
ControlClick(fileupload,$,Button1)
Save it .Au3 format
Then in webdriver write “Runtime.getRuntime().exec("AutoIt .exe filepath");”
Reading data from EXCEL
Step-1: Specify the file path on which you are planning to interact.
FileInputStream fis = new FileInputStream (Filepath);
Step-2: Open WorkBook in Read Mode.
Workbook wb = WorkbookFactory.create(fis);
Step-3: Get the Control of the “Data” Sheet.
Sheet sh = wb.getSheet(“Data”);
Step-4: Get the Control of the 1st Row.
Row row = sh.getRow(1);
Step-5: Read the 2nd cell value from 1st Row.
String userName = row.getCell(2).getStringCellValue();
String Password = row.getCell(3).getStringCellValue();
Test-NG
TestNG is a unit testing framework tool for Core java & .Net languages.
Test-NG is implemented as a plugin for eclipse.
Annotations in TestNG
@Test
@BeforeMethod
@AfterMethod
@BeforeClass
@AfterClass
@BeforeSuite
@AfterSuite
THANK YOU

More Related Content

DOCX
Experienced Selenium Interview questions
PPTX
TDD in the wild
TXT
Excelsheet
PDF
JSRs 303 and 330 in Action
PDF
2nd-Order-SQLi-Josh
PDF
Java Quiz - Meetup
PPTX
SQL and XPATH Injection with Fusion Lite Insight
Experienced Selenium Interview questions
TDD in the wild
Excelsheet
JSRs 303 and 330 in Action
2nd-Order-SQLi-Josh
Java Quiz - Meetup
SQL and XPATH Injection with Fusion Lite Insight

What's hot (19)

PDF
How to identify and prevent SQL injection
TXT
Examplecode
PDF
What's New in Django 1.6
DOC
( 15 ) Office 2007 Create A Membership Database
DOCX
Implement Search Screen Using Knockoutjs
PDF
Ext java-editor
PDF
Accessibility Testing using Axe
PDF
Remote code-with-expression-language-injection
PDF
10 Rules for Safer Code
PDF
Multiple File Upload Control
PPT
Wicket Security Presentation
PDF
ERRest
PDF
Dicoding Developer Coaching #19: Android | Menyimpan Database Secara Local di...
PDF
Appsec usa2013 js_libinsecurity_stefanodipaola
PPTX
Introduction to jQuery - The basics
PPT
Unit testing
PDF
Dvwa low level
PPT
JQuery New Evolution
PDF
Teste de Integração com DbUnit e jIntegrity
How to identify and prevent SQL injection
Examplecode
What's New in Django 1.6
( 15 ) Office 2007 Create A Membership Database
Implement Search Screen Using Knockoutjs
Ext java-editor
Accessibility Testing using Axe
Remote code-with-expression-language-injection
10 Rules for Safer Code
Multiple File Upload Control
Wicket Security Presentation
ERRest
Dicoding Developer Coaching #19: Android | Menyimpan Database Secara Local di...
Appsec usa2013 js_libinsecurity_stefanodipaola
Introduction to jQuery - The basics
Unit testing
Dvwa low level
JQuery New Evolution
Teste de Integração com DbUnit e jIntegrity
Ad

Viewers also liked (8)

PPTX
An introduction to Apache Cordova
PPTX
RESTful Web services in Drupal 8
PPTX
Features module in drupal 8
PPTX
How to Schedule Automated Tasks in Drupal with Cron?
PPTX
Why JSON API?
PPTX
Drupal coding standards and best practices
PPTX
Token module in drupal 8
PPTX
Automation testing for beginners on Selenium
An introduction to Apache Cordova
RESTful Web services in Drupal 8
Features module in drupal 8
How to Schedule Automated Tasks in Drupal with Cron?
Why JSON API?
Drupal coding standards and best practices
Token module in drupal 8
Automation testing for beginners on Selenium
Ad

Similar to How to execute Automation Testing using Selenium (20)

PPTX
Web driver training
PDF
Complete_QA_Automation_Guide__1696637878.pdf
PPTX
Selenium.pptx
PDF
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
PPTX
Selenium training
PDF
Selenium interview questions and answers
PDF
Web UI test automation instruments
PDF
Scraping recalcitrant web sites with Python & Selenium
PPTX
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
PPT
By combining Selenium for frontend testing and tools
PPTX
Selenium web driver
PPSX
Selenium WebDriver
PDF
Automation Testing
PDF
2013 10-10 selenium presentation to ocjug
PPTX
Automation - web testing with selenium
PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
PDF
Latest Selenium Interview Questions And Answers.pdf
DOCX
2. file internal memory
PDF
GDG İstanbul Şubat Etkinliği - Sunum
PDF
Design Patterns in Automation Framework.pdf
Web driver training
Complete_QA_Automation_Guide__1696637878.pdf
Selenium.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Selenium training
Selenium interview questions and answers
Web UI test automation instruments
Scraping recalcitrant web sites with Python & Selenium
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
By combining Selenium for frontend testing and tools
Selenium web driver
Selenium WebDriver
Automation Testing
2013 10-10 selenium presentation to ocjug
Automation - web testing with selenium
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Latest Selenium Interview Questions And Answers.pdf
2. file internal memory
GDG İstanbul Şubat Etkinliği - Sunum
Design Patterns in Automation Framework.pdf

More from valuebound (20)

PDF
Scaling Drupal for High Traffic Websites
PDF
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
PDF
How to Use DDEV to Streamline Your Drupal Development Process.
PDF
How to Use AWS to Automate Your IT Operation| Valuebound
PDF
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
PDF
Mastering Drupal Theming
PDF
The Benefits of Cloud Engineering
PDF
Cloud Computing
PDF
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
PDF
Deep dive into ChatGPT
PDF
Content Creation Solution | Valuebound
PPTX
Road ahead for Drupal 8 contributed projects
PPTX
Chatbot with RASA | Valuebound
PDF
Drupal and Artificial Intelligence for Personalization
PPTX
Drupal growth in last year | Valuebound
PPTX
BE NEW TO THE WORLD "BRAVE FROM CHROME"
PPTX
Event loop in browser
PPTX
The Basics of MongoDB
PPTX
React JS: A Secret Preview
PPTX
Dependency Injection in Drupal 8
Scaling Drupal for High Traffic Websites
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
How to Use DDEV to Streamline Your Drupal Development Process.
How to Use AWS to Automate Your IT Operation| Valuebound
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
Mastering Drupal Theming
The Benefits of Cloud Engineering
Cloud Computing
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
Deep dive into ChatGPT
Content Creation Solution | Valuebound
Road ahead for Drupal 8 contributed projects
Chatbot with RASA | Valuebound
Drupal and Artificial Intelligence for Personalization
Drupal growth in last year | Valuebound
BE NEW TO THE WORLD "BRAVE FROM CHROME"
Event loop in browser
The Basics of MongoDB
React JS: A Secret Preview
Dependency Injection in Drupal 8

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Chapter 3 Spatial Domain Image Processing.pdf

How to execute Automation Testing using Selenium

  • 2. Introduction to Selenium Who named Automation testing tool as Selenium? ● Jason Huggins and team from ThoughtWorks Inc. developed the testing tool in 2004. ● Huggins joked about competitor HP mercury tools saying it cures mercury poisoning by taking Selenium supplements. ● Hence, the name!
  • 3. How to start - Windows 7, 8 and XP Webdriver-To control Browser webDriver driver=new FirefoxDriver(); WebElement-to work with the elements of the page= WebElement element=driver.findelement(By.id(“id”));
  • 4. Methods:- “findElement” is a method in webdriver interface which is used to identify required element in the application.This method takes as an object as an argument of type “By”. Locators:-Webdriver supports 8 locators to identify the element. Types of Locators:- 1.By.id(arg) 2.By.name(string) 3.By.xpath(String xpath expression) 4.By.cssSelector(String selector) 5.By.tagName(String name) 6.By.linkText(string linkText) 7.By.partiallinkText(string linkText) 8.By.className(String className)
  • 5. What is Xpath ? Xpath=//tagname[@attribute=’value’]
  • 7. Select Class Types :- 1.SelectByVisibletext() 2.SelectByIndex() 3.SelectbyValue() 4.deselectAll() 5.isMultiple() 6.getOption() 7.getFirstSelectedOption() 8.getAllSelectedOption()
  • 8. Waits Types:- 1.Normal Wait thread.sleep(20,000) 2.implicitly wait driver.manage().timeouts().implicitlywait(10,TimeUnit.SECONDS) 3.Explicitly wait WebdriverWait=new WebDriverWait(driver.20) wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath( "String Xpath Expression")));
  • 9. Action Class Action class used to perform user interaction operation like mousehover, right-click , double click & keyboard operation. Step-1 : Find a element where we need to perform mouseover operation. WebElement wb = driver.findelement(By.xpath(“….”)); Step-2: Create an object to Action class. Actions act = new Actions(driver); Step-3: Use Mouse over operation : act.moveToelement(wb).perform();
  • 10. Window Handling Step-1: Click the button which opens child window. WebElement wb = driver.findelement(By.xpath(“….”)); Step-2: Get all the current active window Id’s. Set<String> set = driver.getWindowHandles(); Step-3: Using iterator capture the Window Id’s from SET Iterator<String> itr = set.iterator(); String ParentID = itr.next(); String ChildID=itr.next(); Step-4: Pass driver control to child window. driver.switchTo().window(childID);
  • 11. Screenshots Step-1: EventFiringWebDriver dDriver = new EventFiringWebDriver(driver); Step-2: getScreenshotAs() method returns imagefile. File SrcImg = dDriver.getScreenshotAs(OutputType.File) File dstnImag = new File(“c:userscreenshottest.png”) Step-3: Get a help Apache poi, to store image in loca system. FileUtils.copyFile(srcImg , dstimg)
  • 12. How To DownLoad a file from a Browser FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.helperApps.neverAsk.saveToDisk"Mime type of the file”); How To Upload a file in a Browser First we need to install AutoIt WinActive(“$”) fileupload(give the path of the file you want to upload) ControlSetText(fileupload.$,edit1) ControlClick(fileupload,$,Button1) Save it .Au3 format Then in webdriver write “Runtime.getRuntime().exec("AutoIt .exe filepath");”
  • 13. Reading data from EXCEL Step-1: Specify the file path on which you are planning to interact. FileInputStream fis = new FileInputStream (Filepath); Step-2: Open WorkBook in Read Mode. Workbook wb = WorkbookFactory.create(fis); Step-3: Get the Control of the “Data” Sheet. Sheet sh = wb.getSheet(“Data”); Step-4: Get the Control of the 1st Row. Row row = sh.getRow(1); Step-5: Read the 2nd cell value from 1st Row. String userName = row.getCell(2).getStringCellValue(); String Password = row.getCell(3).getStringCellValue();
  • 14. Test-NG TestNG is a unit testing framework tool for Core java & .Net languages. Test-NG is implemented as a plugin for eclipse. Annotations in TestNG @Test @BeforeMethod @AfterMethod @BeforeClass @AfterClass @BeforeSuite @AfterSuite