0

I am trying to get the following selector value:

<span title="Error - Unresolved" class>

my intention is to get the title value in this case --> "Error - Unresolved" Is there a clean, elegant way of doing it? I am using the getText() method but it returns me "" and this is correct but I can't find a way to extract the value of the title in this case.

1 Answer 1

0
  1. If you want to locate the element by HTML title attribute you can do it using XPath selector like:

    WebElement mySpan = driver.findElement(By.xpath("//span[@title='Error - Unresolved']"));
    
  2. If you already have an instance of a WebElement and need to have its title attribute value - go for getAttribute() function like:

    String title = mySpan.getAttribute("title")
    

    enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .