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:

span:contains("Create")

Answers


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

Search




Leave an answer