Skip to content
CodeKruPro

Find elements with basic CSS selectors

Automation taskEasyAsked in: Accenture, Capgemini, Infosys, TCS

"XPath or CSS: which do you prefer?" Many teams reach for CSS first because it is short and readable. Practise the two simplest forms: #id and a tag plus id such as input#email.

CSS Selectors - Basics

Video walkthrough

Watch on YouTube

CSS Selectors - Basics

CSS Selectors are powerful locators that use CSS syntax. Common patterns:

  • #id - find by ID
  • .class - find by class
  • tag - find by tag name
  • tag#id - find by tag with specific ID
  • tag.class - find by tag with specific class

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Find the pre-filled text field using CSS selector #preFilledTextField
  3. Print its value
  4. Find the disabled field using CSS selector input#disabledField
  5. Print its value

Expected output:

Pre-filled value: Codekru
Disabled value: Codekru