Hey testers! 👋 Ready to upgrade your Selenium automation game? In this video, we’re unlocking the most powerful CSS selector tricks every QA needs to know — clean, precise, and perfect for apps like OrangeHRM or any modern web app.
Let’s jump into the top ways to smartly select elements using CSS in Selenium Java:
✅ 1. Parent - Child (Direct Relationship)
Use this when your target is an immediate child of its parent — no skipping levels!
📌 Selector: div - input
🧠 Memory Hack: Strict parenting — direct children only, no grandkids allowed!
✅ 2. Descendant Selector (Any Depth)
Need to select any element nested within another, no matter how deep?
📌 Selector: div input
🧠 Think of it like navigating folders — subfolders, and sub-subfolders included.
✅ 3. Multiple Class Matching
Your element has more than one class? No problem. Just glue them together with no space.
📌 Selector: .btn.primary-btn
🧠 No spaces — treat it like one big selector combo. Like layers on a burger 🍔.
✅ 4. Attribute Starts With (^=)
Target elements whose attribute starts with a specific keyword.
📌 Selector: input[name^='user']
🧠 The ^ symbol means “starts at the top” — think of an upward arrow ⬆️.
✅ 5. Attribute Ends With ($=)
Want to match an attribute that ends with a string?
📌 Selector: input[placeholder$='name']
🧠 $ is like money — it comes at the end 💰.
✅ 6. Attribute Contains (*=)
Use this when you want to match a part of the attribute anywhere in the value.
📌 Selector: input[placeholder*='email']
🧠 * means wildcard — just like searching in Google with partial keywords.
🎯 Bonus Use Case: OrangeHRM Login Page
Let’s put this into action with a real-world form:
Username field → input[placeholder^='User']
Password field → input[placeholder$='word']
Login button → button.oxd-button.orangehrm-login-button
🔍 You just built highly accurate locators — short, stable, and reliable for test automation!
🧠 Ultimate CSS Memory Hack: "PME S-E-C"
Use this acronym to master your selectors:
P → Parent - Child
M → Multiple Classes
E → Ends With ($=)
S → Starts With (^=)
E → Everywhere (descendant)
C → Contains (*=)
Stick this formula in your toolkit and crush those locators like a pro 💪.
🎯 Hashtags :
#AdvancedCSSSelectors, #SeleniumJava, #TestAutomationTips, #WebDriverCSS, #LocatorStrategies, #SeleniumBestPractices, #QACommunity, #AutomationEngineering, #SoftwareTesting, #ElementLocators, #XPathVsCSS, #ParentChildSelector, #CSSSelectorTricks, #AutomationScripting, #PageObjectModel, #OrangeHRMTesting, #RealWorldQA, #WebTesting, #SelectorMagic, #FrontendAutomation, #AutomationScripts, #SeleniumSnippets, #CSSDeepDive, #UIAutomation, #FunctionalTesting, #CSSForQA, #WebLocatorTips, #CSSAttributeSelectors, #AutomationCheatSheet, #QALife
Информация по комментариям в разработке