Search code examples
seleniumappiumappium-android

Appium - not able to get the child element


preconditions: PL: Java java client 7.0.0 Appium server version: 1.13.0 Device Samasung Galaxy S Android Version 9.0

Hello All,

I am trying since a day to get the error text field in email field in screen shot below, but I am not able to get this.

enter image description here

I have already tried the following :

1. actual_textInputError = driver.findElementByXPath("//android.widget.LinearLayout//android.widget.RelativeLayout//android.widget.RelativeLayout//android.widget.LinearLayout//android.widget.FrameLayout//android.widget.LinearLayout//android.widget.FrameLayout//android.widget.TextView").getText();

2.         List<MobileElement> elements = driver.findElements(By.id("textinput_error"));
        for (MobileElement element : elements) {
            actual_textInputError = element.getText();



3.          actual_textInputError = email_Field.findElementByClassName("android.widget.TextView").getText();
        // List <MobileElement> rel_Layouts = driver.findElementsByXPath("*//android.widget.RelativeLayout");

4.  MobileElement layout = (MobileElement)driver.findElementByXPath("//android.widget.RelativeLayout[contains(@resource-id, 'emailInput')]");
        List <MobileElement> errors = driver.findElementsById("textinput_error");
        actual_textInputError = errors.get(0).getText();
        actual_textInputError = errors.get(1).getText();
        actual_textInputError = errors.get(2).getText();
        // MobileElement email_error_field = layout.findElementByXPath("//android.widget.RelativeLayout[contains(@resource-id, 'textinput_error'");
        // actual_textInputError = email_error_field.getText();
/*        for (int i = 0; i<errors.size();i++ ) {
            actual_textInputError = errors.get(0).getText();
        }*/
/*        for (MobileElement rel_Layout : rel_Layouts) {
            actual_textInputError = element.getText();
            System.out.println("error text = " + actual_textInputError);
        }*/
        // actual_textInputError = driver.findElementsByXPath("//android.widget.RelativeLayout//android.widget.TextView").get(0);
        // errorMessage_Text
        //actual_textInputError = errorMessage_Text.getText();

is possible that some one send me the Xpath to search.

many Thanks in advance


Solution

  • Kindly use the below XPath.

    //android.widget.TextView[@text='E-mail address is already in use']