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........");
}
}