SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
In this talk we will delve into one the biggest challenges that Test Automation developers face, finding elements i.e. a robust test means finding the same element with high fidelity while the Application Under Test keeps changing.
We will categorise the methods, and show where developer fail, where machines (Record/Playback) fail, and suggest a new way for locating elements, and analyze the skill-set required to overcome those difficulties.
In this talk we will delve into one the biggest challenges that Test Automation developers face, finding elements i.e. a robust test means finding the same element with high fidelity while the Application Under Test keeps changing.
We will categorise the methods, and show where developer fail, where machines (Record/Playback) fail, and suggest a new way for locating elements, and analyze the skill-set required to overcome those difficulties.
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
1.
Statistical Element Locator
Oren Rubin
And why the Selenium API should evolve!
2.
Testim.io
CEO
Applitools
Director of R&D
Wix
Web Architect
Cadence
Compiler Engineer
IBM
Cloud Engineer
Google Developer Expert
Oren
Rubin
oren@testim.io
Mentor
Google Launchpad
External Lecturer
Technion University
Meetup Co-organizer
Selenium-IL, GDG, Ember
...
3.
Assertions types: Functional, UI, Timing, Memory....
Test
Steps
Setup
Assertions
Stimuli
Setup types: Unit, Integration, or End-To-End
4.
Test
Steps
Setup
Assertions
Stimuli
Assertions types: Functional, UI, Timing, Memory...
Setup types: Unit, Integration, or End-To-End
5.
Stimuli
Mimic User Interaction
on the same element
Locating it based on its
Persistent Properties
6.
Test
Steps
Assertions
Stimuli
Setup
Locate
Action
7.
● Query Languages (Intro)
● Choosing properties
● The Page Objects Solution
○ Locators
○ Web Element
● Why Record/Playback sucks
● The Testim Way
Soon
9.
HTML 101
HTML Elements
● Tag - must
● Properties
● Inner Elements
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
15.
XPath Advantages
Parent Selector: //img/../my-gallery
Text Selector: xxx/text()='some-text'
In CSS4: $img > xxx
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
<xxx>
CSS
vs.
XPath
16.
CSS
vs.
XPath
CSS Advantages
● Web devs know CSS
● Get shortcuts for web
● CSS is a bit faster
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
20.
Id
Uniquely identifies an element in a document
Locate
by
ID Property
21.
Id
Uniquely identifies an element in a document
Locate
by
ID Property
22.
Failure #1
Tips!
● Lookup came up empty
● No code change in this project
● No code change in other projects
● Just ran it again
Locate
by
ID Property
23.
Failure #1
Random Ids
Reusable components usually don't have
consistent ids
Locate
by
ID Property
24.
Failure #2
Tips!
● Lookup came up empty
● HTML changes in this project
● No code change in other projects
Playback
by
ID Property
25.
Failure #2
Code changed
Testing is mostly AOP
Playback
by
ID Property
26.
Failure #3
Tips!
● Didn't find it using jQuery
i.e. $("#my-id") === []
● No code change in this project
● New version in parent project
Locate
by
ID Property
27.
Locate
by
ID Property
Failure #3
Iframes
src has cache killers
...?version=1.4
xxx.com/v1.4/…
Finding the right iframe..
is as hard as finding the element!
28.
Failure #4
Tips!
● Found another element instead
i.e. $("#my-id") === [<other-element>]
● No code change in this project
● No code change in other projects
Locate
by
ID Property
29.
Locate
by
ID Property
Failure #4
Same Id twice!
WTF?!
Find element returns the first element
30.
Failure #5
Tips!
● Works 50% of test runs
● See it, but $("#my-id") finds nothing
● No code change in this project
● No code change in other projects
● No timing issues
Locate
by
ID Property
31.
Failure #5
Two Body-s!
WTF?!Locate
by
ID Property
Some old frameworks suck
32.
Class
Existing properties used for styling
Locate
by
Class Property
33.
Challenge #1
Refactor Style => Fail!
I likeBlonde!
Locate
by
Object Properties
34.
Challenge #2
Non unique > which one?
Locate
by
Object Properties
35.
Locate
by
Object Properties
Nth Child? Just say NO!
Non unique /div/span/div/div/ul/li/div[0]
36.
Text, Link, Partial Links
All considered too fragile
Locate
by
Object Properties
50.
Best Practices
● Non reusable e.g. headers/footers
○ Use Id
● Components
○ Use classes or self debugging symbols
○ Split between
■ Locating the component
■ Locating components’ parts
Page Object Design Pattern =>
Link to my Page Object presentation at SeConf 2014
Locate
by
Object Properties