Certified Selenium Professiona Learning Resources Locating by CSS

Learning Resources
 

Locating by CSS


CSS (Cascading Style Sheets) is a language for describing the rendering of HTML and XML documents. CSS uses Selectors for binding style properties to elements in the document. These Selectors can be used by Selenium as another locating strategy.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 
  
    id="loginForm">
     class="required" name="username" type="text" />
     class="required passfield" name="password" type="password" />
     name="continue" type="submit" value="Login" />
     name="continue" type="button" value="Clear" />
   
 
 
  • css=form#loginForm (3)
  • css=input[name="username"] (4)
  • css=input.required[type="text"] (4)
  • css=input.passfield (5)
  • css=#loginForm input[type="button"] (4)
  • css=#loginForm input:nth-child(2) (5)
 For Support