我突然开始遇到以下错误:
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>
我无法弄清楚为什么突然开始出现此错误。
最佳答案
由于您使用的是Appium 1.7.1,因此请确保使用最新的客户端库5.0.4。
从.m2\repository
清除Maven缓存,并从头开始安装依赖项。
也可能是在定义某些元素时混合了不兼容的注释。在此处查看working examples
关于java - Java Appium PageFactory initElements中的java.lang.IllegalArgumentException @ $ Proxy21错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47674653/