Appium page object model runrime error

android appium

64 观看

1回复

1 作者的声誉

I'm using page object model in Appium testing and getting the following error:

FAILED: login_TC001
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.FluentWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
    at io.appium.java_client.pagefactory.AppiumElementLocator.waitFor(AppiumElementLocator.java:88)
    at io.appium.java_client.pagefactory.AppiumElementLocator.findElement(AppiumElementLocator.java:103)
    at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.intercept(InterceptorOfASingleElement.java:57)
    at io.appium.java_client.android.AndroidElement$$EnhancerByCGLIB$$c0b591f0.sendKeys(<generated>)
    at com.HaulPass.PageObjects.LoginPage.login(LoginPage.java:30)
    at com.HaulPass.Test.HaulPass_LoginPage.login_TC001(HaulPass_LoginPage.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
    at org.testng.TestNG.run(TestNG.java:1031)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

How can I fix it?

Here's my code:

public static AndroidDriver<MobileElement> driver;

    @BeforeTest
    public void driverconfig() {
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 5X");
        cap.setCapability("appPackage", "com.chamberlain.haulpass.delivery");
        cap.setCapability("appActivity", ".login.activity.LoginActivity");
        try {
            driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), cap);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    }

    @Test
    public void login_TC001() {
        LoginPage HaulPassLogin = new LoginPage(driver);
        HaulPassLogin.login("logeshmyqpostman@gmail.com", "L0ginme@001");
    }   
}

public class LoginPage {

    public LoginPage (AndroidDriver<MobileElement> driver){
        PageFactory.initElements(new AppiumFieldDecorator(driver,30,TimeUnit.SECONDS), this);
     }
    @AndroidFindBy (id="com.chamberlain.haulpass.delivery:id/edit_loginlanding_username")
    public MobileElement userName;

    @AndroidFindBy (id="com.chamberlain.haulpass.delivery:id/edit_loginlanding_password")
    public MobileElement password;

    @AndroidFindBy (id="com.chamberlain.haulpass.delivery:id/button_loginlanding_login")
    public MobileElement SignInBtn;

    public void login(String Email, String Password) {
        userName.sendKeys(Email);
        password.sendKeys(Password);
        SignInBtn.click();
    }

}
作者: logeshwaran gopalakrishnan 的来源 发布者: 2017 年 12 月 27 日

回应 1


0

2387 作者的声誉

I don't see obvious issue inside the code, but based on error stacktrace there is might be issue with your dependencies:

  1. make sure you use compatible server/client versions, e.g. 1.7.1, 5.0.4 for java-client in pom.xml / build.gradle
  2. remove old ones and download new ones (e.g. clean .m2 folder if you are using maven and run mvn install in your working directory)
作者: dmle 发布者: 2017 年 12 月 29 日
32x32