Home Ask Login Register

Developers Planet

Your answer is one click away!

david hol February 2016

Get HTML element by text

Consider i have this HTML:

<span class="bla">Create New</span>

How can i get this element ?

I try:



alecxe February 2016

You can use the "by xpath" locator:

driver.findElement(By.xpath("//span[. = 'Create New']"));

lordhazra February 2016

EDIT - xpath selector to get by text:

driver.findElement(By.xpath("//span[contains(.,'Create New')]"));

Post Status

Asked in February 2016
Viewed 1,567 times
Voted 7
Answered 2 times


Leave an answer

Quote of the day: live life