【问题标题】:java.lang.IllegalArgumentException: @$Proxy19: one of [name, xpath, iOSNsPredicate] should be filledjava.lang.IllegalArgumentException: @$Proxy19: [name, xpath, iOSNsPredicate] 之一应填写
【发布时间】:2019-10-28 16:39:42
【问题描述】:

所有 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...

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

【问题讨论】:

  • 你能展示你是如何实现你的页面对象模型的吗?我认为你没有分配 xpath、id 或accessibilityId
  • 感谢@SubanDhyako 的提示。似乎即使它是空的,它也会给出同样的错误。我也在下面为其他人发布了这个解决方案。

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


【解决方案1】:

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

当您在任何 java 类中有 LOCATORS VALUE EMPTY 时会出现此问题。

例如:

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

所以我搜索了 java 类页面工厂中的所有定位器,并输入了所有更正和更新的 xpath、id、链接等。

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

也许这对你也有帮助。

【讨论】:

    【解决方案2】:

    这里要说清楚,错误原因是Xpath为空:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-01
      • 2021-11-12
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 2014-12-07
      • 1970-01-01
      相关资源
      最近更新 更多