Appium is not able to find second element on screen

I have been trying to automate login form of my android. When I run program , It runs proper till Username, It enter username and then after some time it says no element found. So it is not able to find my password text box. I have checked that password text box ID is correct.

My code is given below :

        WebDriver driver = null;

        File classpathRoot = new File(System.getProperty("user.dir"));
        File appDir = new File(classpathRoot, "");
        File app = new File(appDir, "ThreePaid.apk");
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("device", "Android Emulator");
       // capabilities.setSerial("192.168.56.101:5555");
        capabilities.setCapability("platformName", "Android");

        capabilities.setCapability("deviceName","vds");
        capabilities.setCapability("platformVersion", "19");
        capabilities.setCapability("app-package", "air.iNMyBabyPaid"); //Replace with your app's package
        capabilities.setCapability("app-activity", "com.ripl.earlythree.activities.SplashActivty"); //Replace with app's Activity
        capabilities.setCapability("app", app.getAbsolutePath());


 driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub/"), capabilities);

        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);


          WebElement username = driver.findElement(By.id("et_Username"));

           if(username.isDisplayed())
         {


            username.sendKeys("parent");


         }
         else
         {


             System.out.println("Your username element not found");


         }



     WebElement password = driver.findElement(By.id("et_Password"));

         if(password.isDisplayed())

         {

         password.click();
         password.sendKeys("test123");

         }
         else

         {
             System.out.println("Your password element not found");


          }

    }

}

Is the keyboard still being displayed? Password box could be under it, therefore it would not be “visible”. Try closing the keyboard (can be done with the “back” button on android) or use scrollTo to find the element, this is just to see if the ID really works

try replace if condition with try catch.

It can be great if you can share a snapshot of ur object properties…

Yes Simon , Password box is just under username box. But if I will press BACK then it will close my application I think. Can you just tell me by using which property I can focus to “Password” box just after insert username?

Means? Where I can get it? because Appium inspector not working…

How did you got value for this id field, i.e By.id(“et_Username”).

Are working on emulators or real device?

I have same problem running Appium Inspector in Windows, heard that it works fine in iOS.

You can try UiAutomatorViewer which is Google’s tool to identify object properties. You can find this in Android SDK\tools folder.

Ohh…Awesome …UiAutomatorViewer helping me a lot. I can insert password now…thanks a lot…Let me try to now login to app using script…

Please check attached screenshot. How can i find “Signin” button. Because in my app is does not have that type of property by which I can find that button. Do you have any idea?

You have a couple of options:

  • ask the developer to put in a static ID
  • ask the developer to add an accessibility ID
  • use Xpath
  • use android UI automator

Did u tried below:
driver.findElementByXPath("//android.widget.TextView[@text=‘Sign in’]");

Hey ,

Thanks a lot…It is working…I really try to learn that how to create custom xpath but still I could not…Thanks to you again.