【发布时间】: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