Automated UI testing done right (DDDSydney)
-
Upload
mehdi-khalili -
Category
Technology
-
view
13.213 -
download
2
description
Transcript of Automated UI testing done right (DDDSydney)
![Page 1: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/1.jpg)
Automated UI Testing
Done Right
![Page 2: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/2.jpg)
Mehdi KhaliliSenior Developer at Readify
Active Open Source Projects:• BDDfy• Seleno• Humanizer
Blog: www.mehdi-khalili.comTwitter: @MehdiKhalili
![Page 3: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/3.jpg)
These practices are performed by professional developers and testers.
Please DO try this at home
Authorized and written by Mehdi Khalili
![Page 4: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/4.jpg)
framework agnostic ideas and patterns
![Page 5: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/5.jpg)
can apply these with any UI and UI Testing framework
![Page 6: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/6.jpg)
… but for this talk we are going to use
![Page 7: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/7.jpg)
Seleniuman awesome automated UI testing
framework
![Page 8: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/8.jpg)
Seleniumhttp://seleniumhq.org/projects/webdriver/
PM> Install-Package
Selenium.WebDriver
![Page 9: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/9.jpg)
BDDfyA simple BDD framework to use and extend!
BDDfy turns your traditional unit testsinto BDD behaviours
![Page 10: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/10.jpg)
BDDfyhttp://teststack.github.com/TestStack.BDDfy/
PM> Install-Package
TestStack.BDDfy
![Page 11: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/11.jpg)
Selenohelps you write
Automated UI Tests the RIGHT way!
![Page 12: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/12.jpg)
Selenohttp://teststack.github.com/TestStack.Seleno/
PM> Install-Package TestStack.Seleno
![Page 13: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/13.jpg)
samples are from Seleno codebase and can be found at
https://github.com/TestStack/TestStack.Seleno
![Page 14: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/14.jpg)
In a nutshell
• UI Testing: a likely failure• From horrid to awesome in three steps• A few tips (time permitting)• Q&A
![Page 15: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/15.jpg)
UI Testing!a likely failure
![Page 16: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/16.jpg)
speaking of experience
![Page 17: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/17.jpg)
a lot of teamsdo
UI Testing
![Page 18: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/18.jpg)
a lot of teamshave a “great start” at
UI Testing
![Page 19: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/19.jpg)
a lot of teamsthen struggle with
UI Testing
![Page 20: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/20.jpg)
a lot of teamsthen fail atUI Testing
![Page 21: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/21.jpg)
because UI Tests are
![Page 22: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/22.jpg)
because UI Tests are
hard to maintain
![Page 23: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/23.jpg)
because UI Tests are
brittle
![Page 24: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/24.jpg)
but
you can
mitigatethese issues
![Page 25: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/25.jpg)
If you
do it
RIGHT
![Page 26: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/26.jpg)
test codeis
code
![Page 27: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/27.jpg)
apply
S.R.P. on your
code?
![Page 28: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/28.jpg)
apply
S.R.P.on your
tests
![Page 29: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/29.jpg)
apply
D.R.Y.on your
tests
![Page 30: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/30.jpg)
care about your
tests as much as you care about your
code
![Page 31: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/31.jpg)
or you willwaste a lot of time
![Page 32: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/32.jpg)
or you willfail
![Page 33: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/33.jpg)
from horrid to awesomein four three steps
![Page 34: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/34.jpg)
a quick look at the sample
https://github.com/TestStack/TestStack.Seleno
![Page 35: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/35.jpg)
guaranteed to
fail
![Page 36: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/36.jpg)
![Page 37: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/37.jpg)
proceduralduplicated logicduplicated selectorsmagic strings
![Page 38: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/38.jpg)
Step 1:
D.R.Y.your tests with
Page Object
![Page 39: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/39.jpg)
Page Objectbrings
OO to tests)
![Page 40: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/40.jpg)
a Page Object per page under test
![Page 41: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/41.jpg)
a link on the page becomes a
method on the Page Object
![Page 42: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/42.jpg)
clicking a link on the pageturns into calling a method
on the Page Object
![Page 43: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/43.jpg)
instead of
you will get
![Page 44: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/44.jpg)
a textboxon the page becomes a
string propertyon the Page Object
![Page 45: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/45.jpg)
filling a textbox on the page turns into setting a string property on the
Page Object
![Page 46: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/46.jpg)
instead of
you will get
![Page 47: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/47.jpg)
a checkboxon the page becomes a
bool propertyon the Page Object
![Page 48: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/48.jpg)
ticking a checkbox on the page turns into setting a
bool property on the Page Object
![Page 49: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/49.jpg)
any actionon the page becomes a
method on the Page Object
![Page 50: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/50.jpg)
… and you will get another Page Object as the return
value of the method
![Page 51: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/51.jpg)
chain your calls
![Page 52: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/52.jpg)
![Page 53: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/53.jpg)
proceduralduplicating logicduplicating selectorsmagic strings
![Page 54: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/54.jpg)
step 2:
Page Components
Compose your Page Objects of smaller pieces
![Page 55: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/55.jpg)
some pages are
big
![Page 56: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/56.jpg)
some pages are
complex
![Page 57: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/57.jpg)
remember
S.R.P.?
![Page 58: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/58.jpg)
would you write
big and
complex classes in your
code?
![Page 59: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/59.jpg)
care about your tests
as much as you care about your
code
![Page 60: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/60.jpg)
do NOT write
big and
complex Page Objects
![Page 61: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/61.jpg)
use
Page Componentsto break down your
Page Objects
![Page 62: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/62.jpg)
use
Page Componentsfor
gridspanels
rows inmodal pop-ups
menus
![Page 63: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/63.jpg)
Page ComponentsD.R.Y.
your tests even more
![Page 64: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/64.jpg)
instead of
you will get
![Page 65: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/65.jpg)
and you can compose other
Page Objectsusing these
Page Components
![Page 66: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/66.jpg)
![Page 67: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/67.jpg)
Page Object &Page Component
lead into
S.R.P.
![Page 68: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/68.jpg)
Page Object &Page Component
D.R.Y.your test
![Page 69: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/69.jpg)
... but
![Page 70: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/70.jpg)
what about magic strings?
![Page 71: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/71.jpg)
proceduralduplicating logicduplicating selectorsmagic strings
![Page 72: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/72.jpg)
![Page 73: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/73.jpg)
it is not only about
magic strings
![Page 74: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/74.jpg)
the code is still ugly
![Page 75: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/75.jpg)
![Page 76: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/76.jpg)
![Page 77: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/77.jpg)
step 3:
Strongly typedPage Object
![Page 78: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/78.jpg)
you use view models
in your code
![Page 79: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/79.jpg)
![Page 80: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/80.jpg)
why not use view models
in your tests?
![Page 81: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/81.jpg)
![Page 82: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/82.jpg)
(unofficial) step 4:
Tests as Living Documentation
![Page 83: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/83.jpg)
write your UI Tests based on
acceptance criteria
![Page 84: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/84.jpg)
use a BDD framework to implement your
acceptance criteria
![Page 85: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/85.jpg)
use a BDD framework to turn your tests into
living documentation
![Page 86: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/86.jpg)
![Page 87: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/87.jpg)
use the test results
as a progress report
![Page 88: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/88.jpg)
use the test results
as a support for manual testing
![Page 89: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/89.jpg)
A few tips
![Page 90: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/90.jpg)
Do NOT use Thread.Sleep
![Page 91: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/91.jpg)
Thread.Sleepis slow
![Page 92: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/92.jpg)
Thread.Sleepis brittle
![Page 93: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/93.jpg)
often need to wait a bit longer for things to load?
![Page 94: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/94.jpg)
use implicit waits
![Page 95: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/95.jpg)
need to wait longer for specific elements to load?
![Page 96: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/96.jpg)
use explicit waits
![Page 97: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/97.jpg)
need to wait for an AJAX call to finish?
![Page 98: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/98.jpg)
use javascript
![Page 99: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/99.jpg)
chooseright selectors
![Page 100: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/100.jpg)
page structure changes
![Page 101: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/101.jpg)
do NOT
be fuzzywith your selectors
![Page 102: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/102.jpg)
do NOT
rely on the structure of your
page
![Page 103: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/103.jpg)
do NOT
rely on the surrounding elements
![Page 104: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/104.jpg)
By.XPath("//ul[@id='album-list']/li[3]/a/span")
you’re kidding, right?!
![Page 105: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/105.jpg)
we use interfaces and DI all over our code to make it unit testable
![Page 106: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/106.jpg)
do what it takes to
support your tests
![Page 107: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/107.jpg)
be explicit:add id on your elements to
support your tests
![Page 108: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/108.jpg)
TARGET your elements
directlywhen possible
![Page 109: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/109.jpg)
only one test
per action
![Page 110: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/110.jpg)
do you have workflows?
![Page 111: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/111.jpg)
do one test per page/action
![Page 112: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/112.jpg)
then do one test for entire flow
![Page 113: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/113.jpg)
do NOT setup your required
state through UI
![Page 114: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/114.jpg)
that will be slow and brittle
![Page 115: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/115.jpg)
setup your data through code
![Page 116: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/116.jpg)
and navigate to the page under
test directly
![Page 117: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/117.jpg)
use strongly typed actions for that
![Page 118: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/118.jpg)
design byinterface!
when you need it
![Page 119: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/119.jpg)
do you support multiple devices?
![Page 120: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/120.jpg)
do you doA/B testing?
![Page 121: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/121.jpg)
create interface for your Page Objects and
use the interface in your test scripts
![Page 122: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/122.jpg)
ISomePage
PCPage A/B testing pages iPadPage
![Page 123: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/123.jpg)
… and use one test script for all page variations
![Page 124: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/124.jpg)
apply
YAGNIin your
test code
![Page 125: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/125.jpg)
do
NOTcreate a
Page Object
until you need it
![Page 126: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/126.jpg)
do
NOTadd an action to
Page Object
until you need it
![Page 127: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/127.jpg)
do
NOTadd a property to
Page Object
until you need it
![Page 128: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/128.jpg)
do
NOTadd a getter to your property
until you need it
![Page 129: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/129.jpg)
run and maintain your tests
![Page 130: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/130.jpg)
run your tests
frequently
![Page 131: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/131.jpg)
fix the broken test right
when it breaks
![Page 132: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/132.jpg)
tests you do not run
===broken tests
![Page 133: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/133.jpg)
broken tests you do not fix
===ignored tests
![Page 134: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/134.jpg)
… and finally
![Page 135: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/135.jpg)
Confucius says …
![Page 136: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/136.jpg)
UI Testing is hard
![Page 137: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/137.jpg)
and could be a waste of time
![Page 138: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/138.jpg)
so
do NOT do itor
do it RIGHT
![Page 139: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/139.jpg)
when Done Right it is
well worth it
![Page 140: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/140.jpg)
thanks for attending
![Page 141: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/141.jpg)
time for a few Qs & hopefully few As
Blog: www.mehdi-khalili.comTwitter: @MehdiKhalili
http://www.mehdi-khalili.com/presentations/automated-ui-testing-done-right-at-dddsydney
![Page 142: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/142.jpg)
With thanks to our sponsors
![Page 143: Automated UI testing done right (DDDSydney)](https://reader035.fdocuments.us/reader035/viewer/2022081414/549c8fffb47959a5318b47ae/html5/thumbnails/143.jpg)
Please complete your feedback forms, and return
them to the registration desk for a chance to win a
Nokia Lumia