SlideShare a Scribd company logo
Selecting Selectors:
  Using CSS with
     Selenium
     Michelle D’Netto
minimal specificity
Selecting Selectors: Using CSS with Selenium
Selecting Selectors: Using CSS with Selenium
#sign-in
link=Sign In
li.sign-in-link
identical elements
.button-large-cart
.button-large-cart
minimal specificity
long selectors
                   .listings .listing-title a
                                instead of...
body #content #primary #recent_showcase .scroller-view .listings li .listing-title a
summary
Selecting Selectors: Using CSS with Selenium

More Related Content

Recently uploaded (20)

PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
DOCX
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 

Featured (20)

PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
PDF
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
PDF
Everything You Need To Know About ChatGPT
Expeed Software
 
PDF
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
PDF
Skeleton Culture Code
Skeleton Technologies
 
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
PDF
Content Methodology: A Best Practices Report (Webinar)
contently
 
PPTX
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
PDF
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
PDF
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
PDF
Getting into the tech field. what next
Tessa Mero
 
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
PDF
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Ad

Selecting Selectors: Using CSS with Selenium

Editor's Notes

  • #2: - selecting great css selectors, not just good ones\n- limited writing on the interwebs\n- less redesign, more stable and robust tests\n
  • #3: - Be minimally specific - what’s the simplest and most unique way to direct selenium to css elements on our HTML page\n- having id's or classes in your HTML that in some cases will only be used by tests\n- try not to use selectors that are so specific that a harmless redesign will causes tests to fail incorrectly\n\n
  • #4: - so if testing your html is hard for whatever reason, add classes and id's to elements in your HTML so it’s easier to test\n- this lowers the cost of testing (may increase the cost of development/designing)\n- may be of no value to the javascript, designer or user but your tests become more stable\n\n
  • #5: - Sign In element on Etsy’s homepage\n- Use firebug to Inspect Element\n- id, class, title, href, CSS attributes\n
  • #6: selects any element with an id attribute equal to sign-in\n
  • #7: pseudo class selector\nnot a css expression instead it’s a JS function called locateElementByLinkText()\ngrabs all the A elements out of the DOM then loops through them looking for the one whose innerText property matches the regular expression provided (in this case Sign In)\n
  • #8: selects any list item element with a class attribute that contains the word sign-in-link\n\n
  • #9: \n
  • #10: class button-large-cart will get us the element we want (selenium works by selecting the first element that matches)\n
  • #11: using pseudo class again\nselects any input element that is a descendant of any element with a class attribute that contains the word button-large-cart\nmultiple elements with the same class don't seem very easy to handle with pure CSS.  In a Ruby Script, wouldn't you just say "css=button-large-cart", and then assign the resulting list of elements to a Ruby array and work with the Ruby array\n\n\n
  • #12: cases where we want to be vague about elements\n
  • #13: \n
  • #14: Good practice to use css id and class selectors, it’s okay to request them, helps with internationalizing your website\n
  • #15: \n