1

Consider i have this HTML:

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

How can i get this element ?

I try:

span:contains("Create")
david hol
  • 1,184
  • 7
  • 21
  • 38

2 Answers2

1

You can use the "by xpath" locator:

driver.findElement(By.xpath("//span[. = 'Create New']"));
alecxe
  • 441,113
  • 110
  • 1,021
  • 1,148
0

EDIT - xpath selector to get by text:

driver.findElement(By.xpath("//span[contains(.,'Create New')]"));
hazra
  • 401
  • 6
  • 14