SlideShare a Scribd company logo
1 of 20
Download to read offline
Web UI testing in Scala
Radim.pavlicek@gmail.com
@radimpavlicek
Why should I care?
●
●
●
●
●

regression errors
cross web browser (Firefox/IE/Chrome)
cross OS (Mac/Linux/Windows)
cross versions (browsers)
use cases documentation
Selenium
● open-source
● Domain Specific Language support in
ScalaTest 2.0
What’s needed?
● continuous integration (Jenkins)
● server with browser installation
● test-cases from domain users
Recorder
Recorder cont.
+ quickly record
+ no knowledge required
- fragile test cases
- spaghetti test-case
Example
Scenario
Continuous integration
Jenkins

Java application
JSF

Scala code
Selenium
Invoked on Jenkins?
● @Midnight
● Maven
clean integration-test -P ui-test
Maven settings.xml
<profile>
<id>ui-test</id>
<properties>
<onlineUsers.login>rpavlicek</onlineUsers.login>
<onlineUsers.password>*******</onlineUsers.password>
<onlineUsers.url>localhost</onlineUsers.url>
<onlineUsers.port>9090</onlineUsers.port>
</properties>
</profile>
Scala part
Input parameters
object Settings {
val url = System.getProperty ("onlineUsers.url" )
val login = System.getProperty ("onlineUsers.login" )
val password = System.getProperty ("onlineUsers.password" )
val port = {
val tmp = System.getProperty ("onlineUsers.port" )
if (null == tmp)
new Integer(9090)
else new Integer(tmp)
}
}
WebDriver
object WebDriverAccess {
val defaultDriver : WebDriver = {
print("Creating WebDriver... " )
try {
new FirefoxDriver()
} finally { println( "Done.") }
}
}
WebDriver cont.
trait WebDriverAccess {
implicit val driver = WebDriverAccess.defaultDriver
}

implicit = if a parameter value is not supplied
then the compiler will search for an "implicit"
value defined within scope
Page objects pattern
●
●
●
●

model UI as services
not exposing internals
model just what is tested
public service methods return PageObjects
Wait
protected def waitUntil(f: => Boolean): Unit = {
new WebDriverWait(driver, 25, 50) until
(new ExpectedCondition[Boolean] {
def apply(input: WebDriver) = f
})
}
WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long timeOutInSeconds, long
sleepTimeOut)
waitUntil {

!driver.findElements(By.id(“ mainForm:isLoggedIn ”)).isEmpty }
PageObject implementation
abstract class Page[T <: Page[T]]( expectedId: String, val driver:
WebDriver) {
self: T =>
waitUntil {

!driver.findElements(By.id(expectedId)).isEmpty }

private val tmpId: By = By.id(expectedId)
try { driver.findElement(tmpId)
} catch {
case nsee: NoSuchElementException =>
Assert.fail( "ID not found:" +expectedId)
}
}
PageObject cont.
class HomePage( driver: WebDriver) extends Page[HomePage]( "mainForm:
isLoggedIn" , driver) {
def goToUserManagementPage () =
click(id("mainForm:mainNavPTS:0:usersPTText" ))
.expecting[UserManagementPage]

def goToReportPage () =
click(id("mainForm:mainNavPTS:0:reportsPTText" ))
.expecting[ReportPage]
}
Use case
class UserManagementWebTest extends WebDriverAccess {
var homePage: HomePage = _
@Test
def shouldLandOnUserManagement {
val loginPage: LoginPage = LoginPage.open(
server = Settings.url, port = Settings.
port)
homePage = loginPage.login()
val mngPage: UserManagementPage = homePage.goToUserManagementPage()
assertThat(mngPage.text, containsString( "Create new User" ))
}
That’s it!

Q&A

More Related Content

What's hot

Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
Chang W. Doh
 
Transakcyjność w django
Transakcyjność w djangoTransakcyjność w django
Transakcyjność w django
Marcin Baran
 
#win8aca : How and when metro style apps run
#win8aca : How and when metro style apps run#win8aca : How and when metro style apps run
#win8aca : How and when metro style apps run
Frederik De Bruyne
 

What's hot (20)

AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
 
Better Testing With PHP Unit
Better Testing With PHP UnitBetter Testing With PHP Unit
Better Testing With PHP Unit
 
[DN Scrum Breakfast] Protractor: E2E Testing for AngularJS (by Thuy Nguyen)
[DN Scrum Breakfast] Protractor: E2E Testing for AngularJS (by Thuy Nguyen)[DN Scrum Breakfast] Protractor: E2E Testing for AngularJS (by Thuy Nguyen)
[DN Scrum Breakfast] Protractor: E2E Testing for AngularJS (by Thuy Nguyen)
 
Fullstack End-to-end test automation with Node.js, one year later
Fullstack End-to-end test automation with Node.js, one year laterFullstack End-to-end test automation with Node.js, one year later
Fullstack End-to-end test automation with Node.js, one year later
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
The Road to Native Web Components
The Road to Native Web ComponentsThe Road to Native Web Components
The Road to Native Web Components
 
Service worker API
Service worker APIService worker API
Service worker API
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
 
Service worker - Offline Web
Service worker - Offline WebService worker - Offline Web
Service worker - Offline Web
 
Static sites with react
Static sites with reactStatic sites with react
Static sites with react
 
Automated Testing ADF with Selenium
Automated Testing ADF with SeleniumAutomated Testing ADF with Selenium
Automated Testing ADF with Selenium
 
Java Server Faces
Java Server FacesJava Server Faces
Java Server Faces
 
Svelte JS introduction
Svelte JS introductionSvelte JS introduction
Svelte JS introduction
 
CasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingCasperJs Enjoy Functional Testing
CasperJs Enjoy Functional Testing
 
Transakcyjność w django
Transakcyjność w djangoTransakcyjność w django
Transakcyjność w django
 
#win8aca : How and when metro style apps run
#win8aca : How and when metro style apps run#win8aca : How and when metro style apps run
#win8aca : How and when metro style apps run
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
webworkers
webworkerswebworkers
webworkers
 
Service Worker 101 (en)
Service Worker 101 (en)Service Worker 101 (en)
Service Worker 101 (en)
 

Viewers also liked

Tjänster.unicode
Tjänster.unicodeTjänster.unicode
Tjänster.unicode
Sari Salmi
 
Procurement Intelligence Priming Procurement Leaders for Business Power Play
Procurement Intelligence  Priming Procurement Leaders for Business Power PlayProcurement Intelligence  Priming Procurement Leaders for Business Power Play
Procurement Intelligence Priming Procurement Leaders for Business Power Play
Beroe Inc - Advantage Procurement
 

Viewers also liked (20)

Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
 
Encontro com escritor joão morgado
Encontro com escritor joão morgadoEncontro com escritor joão morgado
Encontro com escritor joão morgado
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
Internal combustion engine
Internal combustion engineInternal combustion engine
Internal combustion engine
 
Tjänster.unicode
Tjänster.unicodeTjänster.unicode
Tjänster.unicode
 
Functions In Scala
Functions In Scala Functions In Scala
Functions In Scala
 
Java patterns in Scala
Java patterns in ScalaJava patterns in Scala
Java patterns in Scala
 
3D Printing: An emerging trend and its impact on the MRO supply chain | Beroe...
3D Printing: An emerging trend and its impact on the MRO supply chain | Beroe...3D Printing: An emerging trend and its impact on the MRO supply chain | Beroe...
3D Printing: An emerging trend and its impact on the MRO supply chain | Beroe...
 
Genetically Modified Soybean Seed Patent Expiry
Genetically Modified Soybean Seed Patent ExpiryGenetically Modified Soybean Seed Patent Expiry
Genetically Modified Soybean Seed Patent Expiry
 
Procurement Intelligence Priming Procurement Leaders for Business Power Play
Procurement Intelligence  Priming Procurement Leaders for Business Power PlayProcurement Intelligence  Priming Procurement Leaders for Business Power Play
Procurement Intelligence Priming Procurement Leaders for Business Power Play
 
J unit introduction
J unit introductionJ unit introduction
J unit introduction
 
Conflict Minerals - A Supply Chain Check for Electronic OEMs Industry
Conflict Minerals - A Supply Chain Check for Electronic OEMs IndustryConflict Minerals - A Supply Chain Check for Electronic OEMs Industry
Conflict Minerals - A Supply Chain Check for Electronic OEMs Industry
 
Scala functions
Scala functionsScala functions
Scala functions
 
Brazil telecom market next treasure trove for MVNO's
Brazil telecom market next treasure trove for MVNO'sBrazil telecom market next treasure trove for MVNO's
Brazil telecom market next treasure trove for MVNO's
 
The Future of Procurement - End of Business as Usual
The Future of Procurement - End of Business as UsualThe Future of Procurement - End of Business as Usual
The Future of Procurement - End of Business as Usual
 
Will china remain a low cost country?
Will china remain a low cost country?Will china remain a low cost country?
Will china remain a low cost country?
 
China's Resources Acquisition
China's Resources AcquisitionChina's Resources Acquisition
China's Resources Acquisition
 
Genome editing tools article
Genome editing tools   articleGenome editing tools   article
Genome editing tools article
 
Nagoya Protocol and its Implications on Pharmaceutical Industry
Nagoya Protocol and its Implications on Pharmaceutical IndustryNagoya Protocol and its Implications on Pharmaceutical Industry
Nagoya Protocol and its Implications on Pharmaceutical Industry
 
Propy-LENE Supply! Go Green! On-Purpose Technologies for the Future
Propy-LENE Supply! Go Green! On-Purpose Technologies for the FuturePropy-LENE Supply! Go Green! On-Purpose Technologies for the Future
Propy-LENE Supply! Go Green! On-Purpose Technologies for the Future
 

Similar to Web ui testing

Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
Er. Sndp Srda
 
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
drewz lin
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance tests
Nick Belhomme
 

Similar to Web ui testing (20)

Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
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 training
Selenium trainingSelenium training
Selenium training
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 
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
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Selenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web ApplicationsSelenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web Applications
 
Selenium
SeleniumSelenium
Selenium
 
Browser testing with nightwatch.js
Browser testing with nightwatch.jsBrowser testing with nightwatch.js
Browser testing with nightwatch.js
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance tests
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
Testing in JavaScript - August 2018 - WebElement Bardejov
Testing in JavaScript - August 2018 - WebElement BardejovTesting in JavaScript - August 2018 - WebElement Bardejov
Testing in JavaScript - August 2018 - WebElement Bardejov
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Recently uploaded (20)

THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 

Web ui testing