Appium页面对象模型runrime错误
我使用页面对象模型Appium测试,得到以下错误:Appium页面对象模型runrime错误
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)
我怎样才能解决呢?
这里是我的代码:
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("[email protected]", "[email protected]");
}
}
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();
}
}
回答:
我看不到里面的代码明显的问题,但基于错误的堆栈跟踪有可能是问题与你的依赖:
- 确保您使用兼容的服务器/客户端版本,例如1.7.1,5.0.4 for pom.xml/build.gradle中的java-client
- 删除旧的并下载新的(例如,如果您使用的是maven并在您的工作目录中运行
mvn install
,请清除.m2文件夹)
以上是 Appium页面对象模型runrime错误 的全部内容, 来源链接: utcz.com/qa/266284.html