How to get Text for xpath?

   String text = "";
		String parseText = "";
		for(int i = 0; i < fileCount ; i++){
			String xpath = "//android.widget.RelativeLayout[@resource-id='']["+i+"]"
					+ "//android.widget.TextView";
			text = appium.getText(By.xpath(xpath));

getText method

public String getText(By locator) {
	WebElement element = waitForIsElementPresent(locator);
	return element.getText();

I can not get text
why ?
이미지 5

This is not related to appium, please google :slight_smile:

this is same appium.
in fact. this is real code.

String xpath = “//android.widget.RelativeLayout[@resource-id=‘’][0]”
+ “//android.widget.TextView”;
WebElement element = driver.findElement(xpath);
text = element.getText(element);

but this is not working

element.getText(element); Why ??
just use element.getText();

This won’t work and don’t try this solution
Please try this
Webelement elt=driver.findElement(by.xpath(“yourxpath[contains(text(),“Text you want to search”)]”);