Get the HTML element by text

advertisements

Consider i have this HTML:

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

How can i get this element ?

I try:

span:contains("Create")


You can use the "by xpath" locator:

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