SlideShare a Scribd company logo
Test Automation Using
Selenium
Swati
Email- swati@knoldus.com
History of The Selenium
●

●

Selenium is invent by Jason Huggins
He developed a Javascript library that could drive interactions
with the page, allowing him to automatically rerun tests against
multiple browsers.
Test Automation
●

Test automation is the use of software
To set test preconditions.
To control the execution of tests.
To compare the actual outcomes to predicted outcomes.
To report the Execution Status.

●

Commonly, test automation involves automating
a manual process already in place that uses a
formalized testing process.
Why and When To Automate?
Frequent regression testing
● Repeated test case Execution is required
● User Acceptance Tests
● Faster Feedback to the developers
● Reduce the Human Effort
● Test same application on multiple environments
●
Selenium
●

●

●

Selenium is a robust set of tools that supports rapid
development of test automation for web-based
applications.
Selenium provides a rich set of testing functions
specifically geared to the needs of testing of a web
application.
Selenium operations are highly flexible, allowing many
options for locating UI elements and comparing
expected test results against actual application
behavior.
Selenium Features
●

●

●
●

●
●

Supports Cross Browser Testing. The Selenium
tests can be run on multiple browsers.
Allows scripting in several languages like Java,
C#, PHP and Python.
Ajax/CSS support.
Assertion statements provide an efficient way of
comparing expected and actual results.
Inbuilt reporting mechanism.
Selenium is an open source tool
Selenium Components
●

Selenium IDE

●

Selenium Remote Control

●

Selenium Grid
Selenium IDE
●
●

●

●

●

●

Previously known as Selenium Recorder
Selenium IDE is an integrated development environment
for Selenium tests.
It is implemented as a Firefox extension, and allows you
to record, edit, and replay the test in firefox
Selenium IDE allows you to save tests as HTML, Java,
Ruby scripts, or any other format
It allows you to automatically add assertions to all the
pages.
Allows you to add selenese commands as and when
required
Selence
●

●

Selence special test scripting language for
Selenium.
Selenese provides commands for performing
actions in a browser (click a link, select an
option), and for retrieving data from the
resulting pages.
Selenium IDE Installation
●

First download Mozilla Firefox browser.

●

Click on the Firefox tab present at the top the browser window.

●

In drop down menu click on Add-on.

●

Go to add on page of Mozilla Firefox browser

●

In the search box of Add on page search the term "Selenium IDE" and
press enter

●

Click on more link to the Selenium IDE add-on

●

Go to http://docs.seleniumhq.org/download/

●

Once installation is done the Mozilla Firefox browser will ask you to
restart the browser.Just Restart it.
Selenium IDE - UI
Start and Stop
Recording

Replay
Toolbar

Editor

Accessor
Area

Selenese
Script
Editor

Selenium Log
Recoding a Selenium Test Case
●
●
●
●

●

●

Open Firefox that has the IDE installed
Open the base URL of the application to record.
Keep the application in a common base state.
Go To Tools  Selenium IDE and the IDE will be
opened
Now perform the operations on the application as you
are testing the application.
Once you are done with the recording click on the stop
recording button and save the test case through the file
menu. By default it will be saved as a selenese script
(HTML format)
Creating a Test Suite
●

●

In the Selenium IDE you can
create any number of test
cases and save them as test
suite.
To Run the test Suite click on
the “Play entire test suite”
button as shown below.

Test Suite with
Test1 & test2
Running Options
Run a Test Case
Click the Run button to run the currently displayed test case.

Run a Test Suite
Click the Run All button to run all the test cases in the currently loaded test
suite.

Stop and Start
The Pause button can be used to stop the test case while it is running. The
icon of this button then changes to indicate the Resume button. To
continue click Resume.
Adding Assertions to the Script
●

Selenese allows multiple ways of checking for UI
elements.

●

Verifications and assertions are used to check if

●

an element is present somewhere on the page?

●

specific text is somewhere on the page?

●

specific text is at a specific location on the page?

●

Verifications and assertions are not one and the same.

●

If an assertion fails, the script will be aborted but if a
verification fails the script will continue.
Assertion Statements
●

●

●

●

●

assertTextPresent
This will assert if the text is present in the page.
assertText
This will assert if a particular element is having the particular text.
assertTitle
This will assert if the page is having a proper title.
assertValue
This will assert if a Text box or check box has a particular value
assertElementPresent
This will assert if a particular UI Element is present in the page.
User Acceptance Testing (UAT)
●

●

●

User Acceptance Testing (UAT) is the last phase of the software
testing process. During UAT, actual software users test the
software to make sure it can handle required tasks in real world
scenarios, according to specifications.
UAT is one of the final and critical software project procedures
that must occur before newly developed software is rolled out to
the market.
UAT is also known as beta testing, application testing or end
user testing.
Steps Involved in In-House UAT
●

●

●

●

●

Planning: The UAT strategy is outlined during the planning step.
Designing test cases: Test cases are designed to cover all the
functional scenarios of the software in real-world usage.
Executing test cases and documenting: The testing team executes the
designed test cases. All bugs are logged in a testing document with
relevant comments.
Bug fixing: Responding to the bugs found by the testing team, the
software development team makes final adjustments to the code to
make the software bug-free.
Sign-off: When all bugs have been fixed, the testing team indicates
acceptance of the software application. This shows that the application
meets user requirements and is ready to be rolled out in the market.
Importance of UAT
●

●

UAT is important because it helps demonstrate that required
business functions are operating in a manner suited to realworld circumstances and usage.
UAT is an effective process with a high rate of return for those
who take the time to implement and follow its discipline.
How Selenium Work
Common Problem in Web Testing
●

Record/replay is not reusable, is fragile.

●

Managing test cases.

●

UI changesmake tests brittle.
ScalaTest Using Selenium
●

●

ScalaTest 2.0 includes a domain specific language (DSL) for writing
browser-based tests using Selenium.
To use ScalaTest's Selenium DSL, you'll first need to add Selenium to
your project dependencies. For example, in your sbt build you might
add:
libraryDependencies += "org.seleniumhq.selenium" % "seleniumjava" % "2.23.1" % "test->default"

●

Mix trait WebBrowser into your test class.This trait provides the DSL
in its entirety except for one missing piece : an implicit
org.openqa.selenium.WebDriver
Element Locator
●

ID: id=foo

●

Name: name=foo

●

First ID, then name: identifier=foo

●

DOM: document.forms[‘myform’].myDropdown

●

XPath: xpath=//table[@id='table1']//tr[4]/td[2]

●

Link Text: link=sometext

●

CSS Selector: css=a[href=“#id3”]

●

Sensible defaults, e.g. xpath if starts with //
Example of UAT
class BlogSpec extends FlatSpec with ShouldMatchers with
WebBrowser {
implicit val webDriver: WebDriver = new HtmlUnitDriver
val host = "http://localhost:9000/"
"The blog app home page" should "have the correct title" in {
go to (host + "index.html")
pageTitle should be ("Awesome Blog")
}
}
Terms of Test Cases
●

Navigation:
You can ask the browser to retrieve a page (go to a URL) like this:
go to "http://www.artima.com"

●

Checking input element values:
textField("q").value should be ("Cheese!")
textArea("body").value should be ("I saw something cool today!")

●

Implicit wait :
implicitlyWait(Span(10, Seconds))

●

Cleaning up:
To close all windows, and exit the driver, use quit:
quit()
Test Code of Autocomplete
Functionality
●

Define the autocomplete test code in a trait so that it will be use by all the test class which extends this trait :
trait Reattempt {
def attemptOrReattempAutoComplete(func: By => WebElement, selector: String, searchText: String,Text: String, startWithCount:
Int, maxNumberOfRetries: Int = 5): Unit = {
if (startWithCount <= maxNumberOfRetries && searchText.length > 0) {
func(By.cssSelector(selector)).clear
func(By.cssSelector(selector)).sendKeys(searchText)
try {
if(searchText == Text) {
func(By.cssSelector(“refrence of div where this search text element present")).click
} else {
func(By.cssSelector("refrence of div where this search text element presen")).sendKeys(Keys.ARROW_UP)
}
} catch {
case e: TimeoutException => attemptOrReattempAutoComplete(func, selector, searchText.substring(0, searchText.length 1),Text: String, startWithCount + 1, maxNumberOfRetries)
case e: ElementNotVisibleException => attemptOrReattempAutoComplete(func, selector, searchText.substring(0,
searchText.length - 1), Text: String, startWithCount + 1, maxNumberOfRetries)
}
}
}
}
Sequentially Running Test
To run the whole test cases sequentially we
have to put this line in build.sbt
“parallelExecution in Test := false
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)
parallelExecution in ScctPlugin.ScctTest := false”
Command For Run Acceptace Test
●

To run single test
sbt “test-only packageName.className”

●

To run whole test
sbt test

●

To check the coverage report
sbt scct:test
Selenium Test in Headless Mode
with Xvfb
●

➢

Follow the following steps to configure Xvfb
(Virtual Framebuffer) to run test cases:
install Xvfb on ubuntu using following
command :
sudo apt-get install xvfb

➢

Create .sh file in root /etc/init.d/ folder and
paste the following script code in the script (.sh)
file:
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 +extension GLX +render -noreset -nolisten tcp"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
echo -n "Stopping virtual X frame buffer: Xvfb"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
echo "."
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
exit 1
esac

exit 0
Selenium Test in Headless Mode
with Xvfb
●

Now,open the terminal and go to your project
and run :
Xvfb :1 -screen 0 1920x1080x24 +extension
GLX +render -noreset -nolisten tcp

●

and open another tab of terminal and go to your
project and run :
export DISPLAY=:1
sbt test
Thank You

More Related Content

PPTX
Scala for Test Automation
PDF
Integration Testing With ScalaTest and MongoDB
PPTX
Test automation using selenium
PDF
Selenium Handbook
PDF
Selenium IDE
PPTX
Selenium WebDriver
PPTX
Selenium using Java
 
PDF
Selenium Overview
Scala for Test Automation
Integration Testing With ScalaTest and MongoDB
Test automation using selenium
Selenium Handbook
Selenium IDE
Selenium WebDriver
Selenium using Java
 
Selenium Overview

What's hot (20)

PDF
Mobile Testing with Selenium 2 by Jason Huggins
PPTX
Test Automation and Selenium
PPTX
Selenium ppt
PDF
Selenium presentation
PPTX
Automation - web testing with selenium
PPTX
Automated UI testing done right (DDDSydney)
PPTX
Selenium web driver
DOCX
Selenium WebDriver FAQ's
PDF
Selenium - Introduction
PDF
Selenium Tutorial
PPTX
Protractor Testing Automation Tool Framework / Jasmine Reporters
PDF
Test automation - Building effective solutions
PPTX
Selenium web driver
PDF
Automation Testing using Selenium
PPT
Selenium ide material (1)
PPT
Selenium
PDF
Selenium IDE LOCATORS
PDF
Automation Testing using Selenium Webdriver
PPTX
Selenium Automation
PPT
selenium training | selenium course | selenium video tutorial | selenium for ...
Mobile Testing with Selenium 2 by Jason Huggins
Test Automation and Selenium
Selenium ppt
Selenium presentation
Automation - web testing with selenium
Automated UI testing done right (DDDSydney)
Selenium web driver
Selenium WebDriver FAQ's
Selenium - Introduction
Selenium Tutorial
Protractor Testing Automation Tool Framework / Jasmine Reporters
Test automation - Building effective solutions
Selenium web driver
Automation Testing using Selenium
Selenium ide material (1)
Selenium
Selenium IDE LOCATORS
Automation Testing using Selenium Webdriver
Selenium Automation
selenium training | selenium course | selenium video tutorial | selenium for ...
Ad

Viewers also liked (15)

PPTX
Scaladays 2014 introduction to scalatest selenium dsl
PPTX
Introduction to Selenium Web Driver
PPTX
Automation Testing by Selenium Web Driver
PPT
Selenium
PPT
Selenium
PDF
Monitoring web application behaviour with cucumber-nagios
PPT
Test automation using selenium presented by Quontra Solutions
PPT
Test automation using selenium
PPTX
Selenium and Appium Training from Sauce Labs
PDF
Fullstack End-to-end test automation with Node.js, one year later
PDF
Node.js and Selenium Webdriver, a journey from the Java side
PPT
Selenium
PDF
Selenium Basics Tutorial
PPT
Selenium Concepts
PPT
Selenium ppt
Scaladays 2014 introduction to scalatest selenium dsl
Introduction to Selenium Web Driver
Automation Testing by Selenium Web Driver
Selenium
Selenium
Monitoring web application behaviour with cucumber-nagios
Test automation using selenium presented by Quontra Solutions
Test automation using selenium
Selenium and Appium Training from Sauce Labs
Fullstack End-to-end test automation with Node.js, one year later
Node.js and Selenium Webdriver, a journey from the Java side
Selenium
Selenium Basics Tutorial
Selenium Concepts
Selenium ppt
Ad

Similar to Integrating Selenium testing infrastructure into Scala Project (20)

ODP
Introduction to Selenium
ODP
Selenium ppt
DOCX
What is selenium
PPTX
Mastering Test Automation: How To Use Selenium Successfully
PPTX
Selenium
PPTX
AUTOMATION FRAMEWORK USING SELENIUM & TESTNG ALONG WITH MAVEN
PDF
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
PDF
What's new in selenium 4
PPTX
Slides for Automation Testing or End to End testing
PDF
Quality for developers
PPT
Selenium (1) (1)
PPTX
Selenium
PPTX
PPTX
Selenium
PPTX
Selenium
PPTX
Selenium
PPTX
Automation Testing with Test Complete
PDF
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
PPTX
Software testing tools (free and open source)
PDF
Softwaretestingtoolsfreeandopensourcefinal 150411221750-conversion-gate01
Introduction to Selenium
Selenium ppt
What is selenium
Mastering Test Automation: How To Use Selenium Successfully
Selenium
AUTOMATION FRAMEWORK USING SELENIUM & TESTNG ALONG WITH MAVEN
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
What's new in selenium 4
Slides for Automation Testing or End to End testing
Quality for developers
Selenium (1) (1)
Selenium
Selenium
Selenium
Selenium
Automation Testing with Test Complete
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Software testing tools (free and open source)
Softwaretestingtoolsfreeandopensourcefinal 150411221750-conversion-gate01

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Java 17 features and implementation.pptx
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
Angular Hydration Presentation (FrontEnd)
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Java 17 features and implementation.pptx
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.

Recently uploaded (20)

PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PPTX
Cloud computing and distributed systems.
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
Chapter 2 Digital Image Fundamentals.pdf
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Cloud computing and distributed systems.
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
NewMind AI Monthly Chronicles - July 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
MYSQL Presentation for SQL database connectivity
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology

Integrating Selenium testing infrastructure into Scala Project

  • 2. History of The Selenium ● ● Selenium is invent by Jason Huggins He developed a Javascript library that could drive interactions with the page, allowing him to automatically rerun tests against multiple browsers.
  • 3. Test Automation ● Test automation is the use of software To set test preconditions. To control the execution of tests. To compare the actual outcomes to predicted outcomes. To report the Execution Status. ● Commonly, test automation involves automating a manual process already in place that uses a formalized testing process.
  • 4. Why and When To Automate? Frequent regression testing ● Repeated test case Execution is required ● User Acceptance Tests ● Faster Feedback to the developers ● Reduce the Human Effort ● Test same application on multiple environments ●
  • 5. Selenium ● ● ● Selenium is a robust set of tools that supports rapid development of test automation for web-based applications. Selenium provides a rich set of testing functions specifically geared to the needs of testing of a web application. Selenium operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior.
  • 6. Selenium Features ● ● ● ● ● ● Supports Cross Browser Testing. The Selenium tests can be run on multiple browsers. Allows scripting in several languages like Java, C#, PHP and Python. Ajax/CSS support. Assertion statements provide an efficient way of comparing expected and actual results. Inbuilt reporting mechanism. Selenium is an open source tool
  • 7. Selenium Components ● Selenium IDE ● Selenium Remote Control ● Selenium Grid
  • 8. Selenium IDE ● ● ● ● ● ● Previously known as Selenium Recorder Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and replay the test in firefox Selenium IDE allows you to save tests as HTML, Java, Ruby scripts, or any other format It allows you to automatically add assertions to all the pages. Allows you to add selenese commands as and when required
  • 9. Selence ● ● Selence special test scripting language for Selenium. Selenese provides commands for performing actions in a browser (click a link, select an option), and for retrieving data from the resulting pages.
  • 10. Selenium IDE Installation ● First download Mozilla Firefox browser. ● Click on the Firefox tab present at the top the browser window. ● In drop down menu click on Add-on. ● Go to add on page of Mozilla Firefox browser ● In the search box of Add on page search the term "Selenium IDE" and press enter ● Click on more link to the Selenium IDE add-on ● Go to http://docs.seleniumhq.org/download/ ● Once installation is done the Mozilla Firefox browser will ask you to restart the browser.Just Restart it.
  • 11. Selenium IDE - UI Start and Stop Recording Replay Toolbar Editor Accessor Area Selenese Script Editor Selenium Log
  • 12. Recoding a Selenium Test Case ● ● ● ● ● ● Open Firefox that has the IDE installed Open the base URL of the application to record. Keep the application in a common base state. Go To Tools  Selenium IDE and the IDE will be opened Now perform the operations on the application as you are testing the application. Once you are done with the recording click on the stop recording button and save the test case through the file menu. By default it will be saved as a selenese script (HTML format)
  • 13. Creating a Test Suite ● ● In the Selenium IDE you can create any number of test cases and save them as test suite. To Run the test Suite click on the “Play entire test suite” button as shown below. Test Suite with Test1 & test2
  • 14. Running Options Run a Test Case Click the Run button to run the currently displayed test case. Run a Test Suite Click the Run All button to run all the test cases in the currently loaded test suite. Stop and Start The Pause button can be used to stop the test case while it is running. The icon of this button then changes to indicate the Resume button. To continue click Resume.
  • 15. Adding Assertions to the Script ● Selenese allows multiple ways of checking for UI elements. ● Verifications and assertions are used to check if ● an element is present somewhere on the page? ● specific text is somewhere on the page? ● specific text is at a specific location on the page? ● Verifications and assertions are not one and the same. ● If an assertion fails, the script will be aborted but if a verification fails the script will continue.
  • 16. Assertion Statements ● ● ● ● ● assertTextPresent This will assert if the text is present in the page. assertText This will assert if a particular element is having the particular text. assertTitle This will assert if the page is having a proper title. assertValue This will assert if a Text box or check box has a particular value assertElementPresent This will assert if a particular UI Element is present in the page.
  • 17. User Acceptance Testing (UAT) ● ● ● User Acceptance Testing (UAT) is the last phase of the software testing process. During UAT, actual software users test the software to make sure it can handle required tasks in real world scenarios, according to specifications. UAT is one of the final and critical software project procedures that must occur before newly developed software is rolled out to the market. UAT is also known as beta testing, application testing or end user testing.
  • 18. Steps Involved in In-House UAT ● ● ● ● ● Planning: The UAT strategy is outlined during the planning step. Designing test cases: Test cases are designed to cover all the functional scenarios of the software in real-world usage. Executing test cases and documenting: The testing team executes the designed test cases. All bugs are logged in a testing document with relevant comments. Bug fixing: Responding to the bugs found by the testing team, the software development team makes final adjustments to the code to make the software bug-free. Sign-off: When all bugs have been fixed, the testing team indicates acceptance of the software application. This shows that the application meets user requirements and is ready to be rolled out in the market.
  • 19. Importance of UAT ● ● UAT is important because it helps demonstrate that required business functions are operating in a manner suited to realworld circumstances and usage. UAT is an effective process with a high rate of return for those who take the time to implement and follow its discipline.
  • 21. Common Problem in Web Testing ● Record/replay is not reusable, is fragile. ● Managing test cases. ● UI changesmake tests brittle.
  • 22. ScalaTest Using Selenium ● ● ScalaTest 2.0 includes a domain specific language (DSL) for writing browser-based tests using Selenium. To use ScalaTest's Selenium DSL, you'll first need to add Selenium to your project dependencies. For example, in your sbt build you might add: libraryDependencies += "org.seleniumhq.selenium" % "seleniumjava" % "2.23.1" % "test->default" ● Mix trait WebBrowser into your test class.This trait provides the DSL in its entirety except for one missing piece : an implicit org.openqa.selenium.WebDriver
  • 23. Element Locator ● ID: id=foo ● Name: name=foo ● First ID, then name: identifier=foo ● DOM: document.forms[‘myform’].myDropdown ● XPath: xpath=//table[@id='table1']//tr[4]/td[2] ● Link Text: link=sometext ● CSS Selector: css=a[href=“#id3”] ● Sensible defaults, e.g. xpath if starts with //
  • 24. Example of UAT class BlogSpec extends FlatSpec with ShouldMatchers with WebBrowser { implicit val webDriver: WebDriver = new HtmlUnitDriver val host = "http://localhost:9000/" "The blog app home page" should "have the correct title" in { go to (host + "index.html") pageTitle should be ("Awesome Blog") } }
  • 25. Terms of Test Cases ● Navigation: You can ask the browser to retrieve a page (go to a URL) like this: go to "http://www.artima.com" ● Checking input element values: textField("q").value should be ("Cheese!") textArea("body").value should be ("I saw something cool today!") ● Implicit wait : implicitlyWait(Span(10, Seconds)) ● Cleaning up: To close all windows, and exit the driver, use quit: quit()
  • 26. Test Code of Autocomplete Functionality ● Define the autocomplete test code in a trait so that it will be use by all the test class which extends this trait : trait Reattempt { def attemptOrReattempAutoComplete(func: By => WebElement, selector: String, searchText: String,Text: String, startWithCount: Int, maxNumberOfRetries: Int = 5): Unit = { if (startWithCount <= maxNumberOfRetries && searchText.length > 0) { func(By.cssSelector(selector)).clear func(By.cssSelector(selector)).sendKeys(searchText) try { if(searchText == Text) { func(By.cssSelector(“refrence of div where this search text element present")).click } else { func(By.cssSelector("refrence of div where this search text element presen")).sendKeys(Keys.ARROW_UP) } } catch { case e: TimeoutException => attemptOrReattempAutoComplete(func, selector, searchText.substring(0, searchText.length 1),Text: String, startWithCount + 1, maxNumberOfRetries) case e: ElementNotVisibleException => attemptOrReattempAutoComplete(func, selector, searchText.substring(0, searchText.length - 1), Text: String, startWithCount + 1, maxNumberOfRetries) } } } }
  • 27. Sequentially Running Test To run the whole test cases sequentially we have to put this line in build.sbt “parallelExecution in Test := false concurrentRestrictions in Global += Tags.limit(Tags.Test, 1) parallelExecution in ScctPlugin.ScctTest := false”
  • 28. Command For Run Acceptace Test ● To run single test sbt “test-only packageName.className” ● To run whole test sbt test ● To check the coverage report sbt scct:test
  • 29. Selenium Test in Headless Mode with Xvfb ● ➢ Follow the following steps to configure Xvfb (Virtual Framebuffer) to run test cases: install Xvfb on ubuntu using following command : sudo apt-get install xvfb ➢ Create .sh file in root /etc/init.d/ folder and paste the following script code in the script (.sh) file:
  • 30. XVFB=/usr/bin/Xvfb XVFBARGS=":1 -screen 0 1024x768x24 +extension GLX +render -noreset -nolisten tcp" PIDFILE=/var/run/xvfb.pid case "$1" in start) echo -n "Starting virtual X frame buffer: Xvfb" start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS echo "." ;; stop) echo -n "Stopping virtual X frame buffer: Xvfb" start-stop-daemon --stop --quiet --pidfile $PIDFILE echo "." ;; restart) $0 stop $0 start ;; *) echo "Usage: /etc/init.d/xvfb {start|stop|restart}" exit 1 esac exit 0
  • 31. Selenium Test in Headless Mode with Xvfb ● Now,open the terminal and go to your project and run : Xvfb :1 -screen 0 1920x1080x24 +extension GLX +render -noreset -nolisten tcp ● and open another tab of terminal and go to your project and run : export DISPLAY=:1 sbt test