java.lang.IllegalArgumentException:@ $ Proxy19:应填写[名称,xpath,iOSNsPredicate]中的一种

时间:2019-06-14 04:36:58

标签: java xpath appium appium-android appium-ios

所有xpath都是最新的,并且每当我运行脚本时,仍然会在下面出现此问题。

java.lang.IllegalArgumentException: @$Proxy19: one of [uiAutomator, accessibility, className, id, tagName, name, xpath, linkText, partialLinkText, windowsAutomation, iOSClassChain, iOSNsPredicate] should be filled

  java.lang.IllegalArgumentException: @$Proxy19: one of [uiAutomator, accessibility, className, id, tagName, name, xpath, linkText, partialLinkText, windowsAutomation, iOSClassChain, iOSNsPredicate] should be filled
    at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.getFilledValue(AppiumByBuilder.java:109)
    at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.createBy(AppiumByBuilder.java:148)
    at io.appium.java_client.pagefactory.DefaultElementByBuilder.getBys(DefaultElementByBuilder.java:133)
    at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildMobileNativeBy(DefaultElementByBuilder.java:182)
    at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildBy(DefaultElementByBuilder.java:216)
    at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:66)
    at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:53)
    at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:1)
    at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:56)
    at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:155)
    at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113)
    at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
    at com.hlb.mobileautomation.pages.AccountSummaryPage.<init>(AccountSummaryPage.java:22)
    at com.hlb.mobileautomation.stepdefinitions.MainSteps.user_navigates_to_quick_links_for_send_money(MainSteps.java:263)
    at ✽.Then user navigates to quick links for send money(src/test/resources/features/FundTranferFavoriteAccount.feature:37)

失败的方案: src / test / resources / features / FundTranferFavoriteAccount.feature:43#方案概述:首次登录应用程序

1 Scenarios (1 failed)
4 Steps (1 failed, 3 passed)
2m2.672s

java.lang.IllegalArgumentException: @$Proxy19: one of [uiAutomator, accessibility, className, id, tagName, name, xpath, linkText, partialLinkText, windowsAutomation, iOSClassChain, iOSNsPredicate] should be filled
    at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.getFilledValue(AppiumByBuilder.java:109)
    at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.createBy(AppiumByBuilder.java:148)
    at io.appium.java_client.pagefactory.DefaultElementByBuilder.getBys(DefaultElementByBuilder.java:133)
    at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildMobileNativeBy(DefaultElementByBuilder.java:182)
    at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildBy(DefaultElementByBuilder.java:216)
    at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:66)
    at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:53)
    at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:1)
    at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:56)
    at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:155)
    at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113)
    at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
    at com.hlb.mobileautomation.pages.AccountSummaryPage.<init>(AccountSummaryPage.java:22)
    at com.hlb.mobileautomation.stepdefinitions.MainSteps.user_navigates_to_quick_links_for_send_money(MainSteps.java:263)
    at ✽.Then user navigates to quick links for send money(src/test/resources/features/FundTranferFavoriteAccount.feature:37)

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 125.135 sec <<< FAILURE! - in TestSuite
feature(com.hlb.mobileautomation.runner.RunCukesTest)  Time elapsed: 123.002 sec  <<< FAILURE!
cucumber.runtime.CucumberException: java.lang.IllegalArgumentException: @$Proxy19: one of [uiAutomator, accessibility, className, id, tagName, name, xpath, linkText, partialLinkText, windowsAutomation, iOSClassChain, iOSNsPredicate] should be filled
    at com.hlb.mobileautomation.runner.RunCukesTest.feature(RunCukesTest.java:39)
Caused by: java.lang.IllegalArgumentException: @$Proxy19: one of [uiAutomator, accessibility, className, id, tagName, name, xpath, linkText, partialLinkText, windowsAutomation, iOSClassChain, iOSNsPredicate] should be filled

结果:

测试失败:

RunCukesTest.feature:39 » Cucumber java.lang.IllegalArgumentException: @$Proxy...

我将页面对象模型与黄瓜一起使用。

2 个答案:

答案 0 :(得分:0)

我正在将页面工厂与黄瓜一起使用。

当任何Java类中都有LOCATORS VALUE EMPTY时,就会发生此问题。

例如:

@iOSXCUITFindBy(xpath="")
@AndroidFindBy(id="vn.com.nitin.test.uat:id/hamburger_menu")
private MobileElement hamburger_menu;

所以我搜索了Java类页面工厂中的所有定位符,然后输入了所有更正和更新的xpath,id,链接等。

在那之后,一切对我都很好。

也许对您也有帮助。

答案 1 :(得分:0)

仅在此处说明一下,错误原因是由于空的Xpath:

@AndroidFindBy(xpath = "")
private MobileElement abc;