SlideShare a Scribd company logo
Statistical Element Locator
Oren Rubin
And why the Selenium API should evolve!
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
...
Assertions types: Functional, UI, Timing, Memory....
Test
Steps
Setup
Assertions
Stimuli
Setup types: Unit, Integration, or End-To-End
Test
Steps
Setup
Assertions
Stimuli
Assertions types: Functional, UI, Timing, Memory...
Setup types: Unit, Integration, or End-To-End
Stimuli
Mimic User Interaction
on the same element
Locating it based on its
Persistent Properties
Test
Steps
Assertions
Stimuli
Setup
Locate
Action
● Query Languages (Intro)
● Choosing properties
● The Page Objects Solution
○ Locators
○ Web Element
● Why Record/Playback sucks
● The Testim Way
Soon
Intro: Query Languages
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>
Selectors
Tag Name
CSS selector: my-gallery
XPath: //my-gallery
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
Properties
CSS selector: [class=gallery]
Fine tuning: [class=~gallery]
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
Selectors
Class Selector: .im
ID Selector: #id
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
Shortcuts
Selectors
Find element inside another element (using space)
css: .gallery .im
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
Child Selector
Selectors
Logical “And” (&&)
By snapping selectors
CSS Selector: img.[title=1]
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
Selectors
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
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>
Object Based Choosing properties
Which properties to choose
● Id
● Class
● Tag name
● Text
● Css selector
● XPath
● Link || partial link
● ...
Object Based
Find the problem game!
Id
Uniquely identifies an element in a document
Locate
by
ID Property
Id
Uniquely identifies an element in a document
Locate
by
ID Property
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
Failure #1
Random Ids
Reusable components usually don't have
consistent ids
Locate
by
ID Property
Failure #2
Tips!
● Lookup came up empty
● HTML changes in this project
● No code change in other projects
Playback
by
ID Property
Failure #2
Code changed
Testing is mostly AOP
Playback
by
ID Property
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
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!
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
Locate
by
ID Property
Failure #4
Same Id twice!
WTF?!
Find element returns the first element
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
Failure #5
Two Body-s!
WTF?!Locate
by
ID Property
Some old frameworks suck
Class
Existing properties used for styling
Locate
by
Class Property
Challenge #1
Refactor Style => Fail!
I likeBlonde!
Locate
by
Object Properties
Challenge #2
Non unique > which one?
Locate
by
Object Properties
Locate
by
Object Properties
Nth Child? Just say NO!
Non unique /div/span/div/div/ul/li/div[0]
Text, Link, Partial Links
All considered too fragile
Locate
by
Object Properties
Page Objects
Page Objects
Will not be covered!
Link to Page Object Done Right
Separation of Concerns
Class Gallery () { … }
Class Image () { … }
<body>
<article>
<my-gallery class=gallery>
<img class="im f1" title=1> <img class="im f2" title=2>
Page Objects
(Component Objects)
Option 1 - String (Locator) Concatination
Page Objects
(Component Objects)
Class Gallery () {
WebElement galleryLocator;
Gallery(String galleryLocator) {
this.galleryLocator = galleryLocator;
}
ShowFullScreen() {
this.find(galleryLocator + “ ” + “img”).click();
}
}
Option 2 - WebElement
Page Objects
(Component Objects)
Class Gallery () {
WebElement galleryElement;
Gallery(WebElement galleryElement) {
this.galleryElement = galleryElement
}
ShowFullScreen() {
galleryElement.find(“img”).click();
}
}
WebElement
VS
Locators (Strings)
Record /
Playback
Why Record / Playback Suck?
Because It’s hard
Meet Selenium IDE
Record /
Playback
Unreliable, Unreadable, Uneditable
Record /
Playback
Meet Usetrace
Meet Testim.io
Locate via Statistical Analysis & Crowd Wisdom
Locate
by
Object Properties
Testim Capture
Announcing
Testim Capture
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
Thank you :)
oren@testim.io | @shexman | linkedin
Oren Rubin

More Related Content

PPTX
Test automation expert days
PDF
Test automation & Seleniun by oren rubin
PDF
Making cross browser tests beautiful
PDF
UI Testing Best Practices - An Expected Journey
PPTX
DSL, Page Object and Selenium – a way to reliable functional tests
PDF
Introduction To Web Application Testing
PPTX
Angular UI Testing with Protractor
PPTX
Automated UI Testing Done Right (QMSDNUG)
Test automation expert days
Test automation & Seleniun by oren rubin
Making cross browser tests beautiful
UI Testing Best Practices - An Expected Journey
DSL, Page Object and Selenium – a way to reliable functional tests
Introduction To Web Application Testing
Angular UI Testing with Protractor
Automated UI Testing Done Right (QMSDNUG)

What's hot (20)

PDF
Selenium - The page object pattern
PPTX
Marcin Wasilczyk - Page objects with selenium
PDF
AngularJS and Protractor
PPTX
Protractor training
PDF
APIs: A Better Alternative to Page Objects
PDF
Automation Abstraction Layers: Page Objects and Beyond
PPTX
Protractor survival guide
PDF
Real World Selenium Testing
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
PDF
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
PPTX
Protractor Tutorial Quality in Agile 2015
PDF
Front-end Automated Testing
PPTX
Selenium Design Patterns
PPTX
An Introduction to AngularJS End to End Testing using Protractor
PPTX
Better Page Object Handling with Loadable Component Pattern
PDF
Easy automation.py
PPTX
Design patterns in web testing automation with WebDriver
PPTX
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
PPTX
Automated UI testing done right (DDDSydney)
Selenium - The page object pattern
Marcin Wasilczyk - Page objects with selenium
AngularJS and Protractor
Protractor training
APIs: A Better Alternative to Page Objects
Automation Abstraction Layers: Page Objects and Beyond
Protractor survival guide
Real World Selenium Testing
Better End-to-End Testing with Page Objects Model using Protractor
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Protractor Tutorial Quality in Agile 2015
Front-end Automated Testing
Selenium Design Patterns
An Introduction to AngularJS End to End Testing using Protractor
Better Page Object Handling with Loadable Component Pattern
Easy automation.py
Design patterns in web testing automation with WebDriver
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
Automated UI testing done right (DDDSydney)
Ad

Similar to Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016 (20)

PDF
Efficient Rails Test-Driven Development - Week 6
PDF
2010 07-18.wa.rails tdd-6
PPTX
Java scriptforjavadev part2a
PPTX
SharePoint Cincy 2012 - jQuery essentials
PPTX
Page Fragments как развитие идеи Page Object паттерна
PDF
kranonit S04E02 Кирил Jstor: Hacking .NET applications
PDF
Advanced guide to develop ajax applications using dojo
PPTX
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
ODP
Behat Workshop at WeLovePHP
PDF
The Hack Spectrum: Tips, Tricks, and Hacks for Unity
PDF
Escaping Test Hell - ACCU 2014
PPTX
Getting started with jQuery
PDF
2016 stop writing javascript frameworks by Joe Gregorio
PDF
Top100summit 谷歌-scott-improve your automated web application testing
PPTX
Entity Framework Today (May 2012)
PPTX
ppt- u 2.pptx
PDF
The Django Book, Chapter 16: django.contrib
PDF
TDD with phpspec2
PDF
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
PPTX
Productivity Enhencement with Visual Studio
Efficient Rails Test-Driven Development - Week 6
2010 07-18.wa.rails tdd-6
Java scriptforjavadev part2a
SharePoint Cincy 2012 - jQuery essentials
Page Fragments как развитие идеи Page Object паттерна
kranonit S04E02 Кирил Jstor: Hacking .NET applications
Advanced guide to develop ajax applications using dojo
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
Behat Workshop at WeLovePHP
The Hack Spectrum: Tips, Tricks, and Hacks for Unity
Escaping Test Hell - ACCU 2014
Getting started with jQuery
2016 stop writing javascript frameworks by Joe Gregorio
Top100summit 谷歌-scott-improve your automated web application testing
Entity Framework Today (May 2012)
ppt- u 2.pptx
The Django Book, Chapter 16: django.contrib
TDD with phpspec2
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Productivity Enhencement with Visual Studio
Ad

Recently uploaded (20)

PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Nekopoi APK 2025 free lastest update
PDF
AI in Product Development-omnex systems
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
history of c programming in notes for students .pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Transform Your Business with a Software ERP System
PPTX
L1 - Introduction to python Backend.pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPT
Introduction Database Management System for Course Database
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Operating system designcfffgfgggggggvggggggggg
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Nekopoi APK 2025 free lastest update
AI in Product Development-omnex systems
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
CHAPTER 2 - PM Management and IT Context
Navsoft: AI-Powered Business Solutions & Custom Software Development
history of c programming in notes for students .pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
ManageIQ - Sprint 268 Review - Slide Deck
Transform Your Business with a Software ERP System
L1 - Introduction to python Backend.pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
Introduction Database Management System for Course Database
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...

Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016