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,272
  • 7
  • 22
  • 44

2 Answers2

1

You can use the "by xpath" locator:

driver.findElement(By.xpath("//span[. = 'Create New']"));
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
0

EDIT - xpath selector to get by text:

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