Java Appium PageFactory initElements 中的 java.lang.IllegalArgumentException @$Proxy21 错误
Posted
技术标签:
【中文标题】Java Appium PageFactory initElements 中的 java.lang.IllegalArgumentException @$Proxy21 错误【英文标题】:java.lang.IllegalArgumentException @$Proxy21 error in Java Appium PageFactory initElements 【发布时间】:2018-05-20 08:32:18 【问题描述】:我突然开始面临以下错误:
java.lang.IllegalArgumentException: 如果使用“@$Proxy21”注解,则不得同时使用“@$Proxy23”注解 在 io.appium.java_client.pagefactory.DefaultElementByBuilder.checkDisallowedAnnotationPairs(DefaultElementByBuilder.java:46) 在 io.appium.java_client.pagefactory.DefaultElementByBuilder.assertValidAnnotations(DefaultElementByBuilder.java:87)
我正在使用下面的代码来初始化元素:
PageFactory.initElements(new AppiumFieldDecorator(appiumDriver, 6, TimeUnit.SECONDS), this);
一切正常,没有任何重大变化,但现在失败了。
Appium 版本:1.7.1
我的 POM.xml
<dependencies>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>$jackson.version</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>$jackson.version</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>$selenium.java.version</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>$cucumber.extentsreport.version</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>$appium.java-client.version</version>
<!--<version>5.0.0-BETA5</version>-->
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>$log4j.version</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>$cucumber-java.version</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>$json-path.version</version>
</dependency>
<dependency>
<groupId>org.monte.screenrecorder</groupId>
<artifactId>MonteScreenRecorder</artifactId>
<version>10</version>
<scope>system</scope>
<systemPath>$basedir/lib/monte-screen-recorder-0.7.7.jar</systemPath>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>$junit.version</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>$cucumber-junit.version</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>$cucumber-junit.version</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>$json-simple.version</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<!--<dependency>-->
<!--<groupId>org.seleniumhq.selenium</groupId>-->
<!--<artifactId>selenium-chrome-driver</artifactId>-->
<!--<version>3.3.1</version>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-context</artifactId>-->
<!--<version>$spring-context.version</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>$hamcrest-library.version</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>test</scope>
</dependency>
<!--Exploratory Cucumber-TestNG Fusion-->
<!--<dependency>-->
<!--<groupId>info.cukes</groupId>-->
<!--<artifactId>cucumber-testng</artifactId>-->
<!--<version>1.2.4</version>-->
<!--<scope>compile</scope>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>junit</groupId>-->
<!--<artifactId>junit</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>info.cukes</groupId>-->
<!--<artifactId>cucumber-spring</artifactId>-->
<!--<version>$cucumber-spring.version</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-context</artifactId>-->
<!--<version>4.3.8.RELEASE</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-test</artifactId>-->
<!--<version>4.3.8.RELEASE</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-engine</artifactId>
<version>5.0.0-ALPHA</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
<scope>test</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.testobject</groupId>-->
<!--<artifactId>testobject-appium-java-api</artifactId>-->
<!--<version>0.1.0</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.browserstack</groupId>
<artifactId>browserstack-local-java</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>report.donut</groupId>
<artifactId>donut</artifactId>
<version>1.1</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.browserstack</groupId>-->
<!--<artifactId>automate-testassist</artifactId>-->
<!--<version>0.7.2-SNAPSHOT</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.browserstack</groupId>-->
<!--<artifactId>browserstack-integration</artifactId>-->
<!--<version>LATEST</version>-->
<!--</dependency>-->
</dependencies>
我无法弄清楚为什么我突然开始收到此错误。
【问题讨论】:
【参考方案1】:确保使用最新的客户端库,即 5.0.4,因为您使用的是 Appium 1.7.1。
从 .m2\repository
清理 maven 缓存并从头开始安装依赖项。
也可能是您在定义某些元素时混合了不兼容的注释。在这里查看working examples
【讨论】:
以上是关于Java Appium PageFactory initElements 中的 java.lang.IllegalArgumentException @$Proxy21 错误的主要内容,如果未能解决你的问题,请参考以下文章
Java Appium PageFactory initElements 中的 java.lang.IllegalArgumentException @$Proxy21 错误
Appium Pagefactory 从 POM 运行时抛出 noSuchMethodException
AndroidPageObjectTest_TimeOutManagement.java
AndroidPageObjectTest_Simple.java