How to Detect Span Text in a Hybrid App

How to Detect Text in a Hybrid App?
Appium Desktop: 1.6.1
Appium Server: 1.8.1
java-client: 6.1.0
I have been trying different ways, however none of them appear to be working 100%. One thing I tried was to use element.isDisplayed() on a xpath like this “//div[contains(text(),’” + text + “’)]”. This worked but only for div elements. It certainly does not work on any span elements even if I were to change div to span.

Here is the span element I am unable to access. Even with the full xpath copies straight from the Chrome inspector I was unable to even reach the element and so I definitely cannot check the text inside if the Xpath fails.

Here is the second method I tried:

	public boolean searchForText(String text, String xpath, int wait) 
		boolean result;
		System.out.println("Searching for: " + text);
		WebElement target = findByXPath(xpath, BUTTON_WAIT);
		String actual = target.getText();
		System.out.println("Actual: " + actual);
			result =  true;
		}else {
			result = false;
		System.out.println("Found: " + result);
		return result;

After much trial and error I fixed the code! I’ve come to the conclusion that (in my case) span text can only be accessed from the div that the span is nested in. If you know any alternatives feel free to share. Here is my working code:

WebElement element = (WebElement)(d.findElements(By.xpath("//div[@class='ERROR_CLASS_NAME']")).get(1)); //in my case there are more than one div matching this xpath, thus the .get(1)
		String actual = element.getText();
		String expected = "EMPTY PASSWORD ERROR";
		if(actual.equals(expected)) {
		}else {