-1

The element in question is this:

<p class="boxMessage">Invalid credentials entered. Re-enter the required credentials.</p>

So far I've tried both getText() and getAttribute().

Gokul
  • 788
  • 2
  • 12
  • 30
Reez0
  • 2,512
  • 2
  • 17
  • 39
  • 1
    Is the element visible? If not, getText() would return nothing, but you can use a solution from [this question](https://stackoverflow.com/questions/13047056/how-to-read-text-from-hidden-element-with-selenium-webdriver) – Alex Oct 18 '17 at 11:49

1 Answers1

2

You can try WebElement.getAttribute("value") or you can also try the innerText attribute that will return the text content of an element.

 element.getAttribute("innerText")

or You can also bring the element into the viewport by scrolling to it

((JavaScriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", element);

and then try the getText() .

Mudassar
  • 3,135
  • 17
  • 22