How can I easily loop in all the last TextView ? without this absolute path ??
I need to check for specific “text” value for all the TextView[1] / TextView[2] / TextView[3] … / TextView[11] in bold above !
How can I easily loop in all the last TextView ? without this absolute path ??
I need to check for specific “text” value for all the TextView[1] / TextView[2] / TextView[3] … / TextView[11] in bold above !
You can use AppiumDriver.findElements() to find all elements that match the same locator.
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver
AppiumDriver driver = MobileDriverFactory.getDriver()
List elements = driver.findElements(By.xpath("//hierarchy/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.TextView"))
for (WebElement e in elements) {
println e.getText()
}
findElements(By.xpath(“…/android.widget.LinearLayout[1]/android.widget.TextView”)) will return all TextView elements under the LinearLayout parent