Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CSS Selectors in Java
// css ID
driver.findElement((By.cssSelector("#user-name")));
// Input elemenet with class form_input
driver.findElement(By.cssSelector("input.form_input"));
// Direct child
driver.findElement(By.cssSelector("form > input"));
// using attribute. Input with id='user-name'
driver.findElement(By.cssSelector("input[id='user-name']"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment