Mendix native app automation (android + iOS)

I am trying to automate mendix Native app: (android+ios)

I have written a Test script on Eclipse IDE using Selenium(java)+Appium(uiautomator2).
Whenever I try to run the test script , It launches the emulator and opens the AUT. It is able to locate the app elements, It passes login credentials and successfully clicks on login button.

But after clicking login button, It shows error : please enter username and password…

CODE:

package appiumtests;

import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;

public class AppiumTest {
//WebDriver driver; // selenium web driver
static AppiumDriver driver; //appium mobile testing driver
//AndroidDriver driver; //android device testing driver
//iOSDriver driver;
public static void main(String[] args) {
try {
openApp();
}catch(Exception exp) {
System.out.println(exp.getCause());
System.out.println(exp.getMessage());
exp.printStackTrace();
}
}

public static void  openApp() throws Exception{
	
	DesiredCapabilities cap = new DesiredCapabilities();
	cap.setCapability("deviceName", "emulator-5554");
	cap.setCapability("platformName", "Android");
	cap.setCapability("platformVersion", "12.0");
	cap.setCapability("automationName", "uiautomator2");
	cap.setCapability("appPackage", "app.connectedce.test");
	cap.setCapability("appActivity", "com.mendix.nativetemplate.MainActivity");
	
	Thread.sleep(10000);
	
	URL url = new URL("http://127.0.0.1:4723/wd/hub");  //appium server web
	driver = new AppiumDriver<MobileElement>(url,cap);
	driver.manage().timeouts().implicitlyWait(300000, TimeUnit.SECONDS);
	
	System.out.println("Application Started........");

	MobileElement el1 = (MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[1]/android.widget.EditText");

	el1.click();
	el1.sendKeys("************");
	System.out.println("UserName entered........");

	MobileElement el2 = (MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.widget.EditText");

	el2.click();
	el2.sendKeys("**********");
	System.out.println("Password entered........");

	MobileElement el3 = (MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[3]/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup");
	
            el3.click();
	System.out.println("Login button clicked........");

}

}

Have you tried this manually with the emulator? It seems like a problem with the app.

If Appium is putting correct credentials and clicking correct button (which you are verifying by watching) then there must be a problem with the app, or could there be another button to click?

I tried the process manually , It is working fine

on appium inspector , i tried with setting desired capability, (automationName : espresso), then it is able to login when inspector is running, but whenever i try to run the script through Eclipse(appium+selenium) , then it is thowing some error …It launches the app but suddenly it closes the app…

So now it’s crashing? Take a look at the app log (if you can).

It’s very strange that you are using Espresso and it crashes, but Uiautomator basic functionality doesn’t work. Must be the most unstable app ever created.

I notice you even tried iOS Driver (now commented out). That must have been fun.

Is there any setup for espresso driver, which i need to do in eclipse?

getting this error whenever i try to run the script(espresso driver)

Maybe Eclipse forums would know?

how to locate the dynamic elements? --i am using xpath ,but still it showing ,no such element found

Have you thought about doing a basic tutorial? You say you are using Espresso, here is such a tutorial:

https://www.headspin.io/blog/using-espresso-with-appium

issue resolved,Thanks wreed ,

1 Like

I faced similar issue. Before or after entering your password, do a click() function in the password field and then login. This method worked for me.