3

I am new to selenium.

How do search for an element with multiple classes and value.

<div class="md-tile-text--primary md-text">Getting Started</div>

using findElement By .css Selector.

1 Answer 1

3

To identify the node:

div class="md-tile-text--primary md-text">Getting Started

You can use the following cssSelector:

driver.findElement(By.cssSelector("div.md-tile-text--primary.md-text"));

To construct a cssSelector based on the text Getting Started you can use:

driver.findElement(By.cssSelector("div:contains('Getting Started')"));
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks Debanjan, How to also select based on text value in the above case "Getting Started"
will do deb, but still looking for a solution for the above question
Thanks deb that worked, only need to how know how to include the text "Getting Started" in the criteria
Thanks Deb, i am unable to vote now as i dont have more than 15 reputation.
driver.findElement(By.cssSelector("div.md-tile-text--primary.md-text")); driver.findElement(By.cssSelector("div:contains('Getting Started')")); How to combine both the above statements into one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.