无法滚动日历表单(日期,月份,年份)

时间:2019-06-02 07:43:35

标签: selenium selenium-webdriver appium appium-android

我正在尝试滚动出生日历以选择日期,月份和年份。 每列都可以单独滚动。

我无法滚动并选择特定的出生日期,例如1964年1月12日

enter image description here

我在获得出生日历后尝试过

WebElement dayPicker = driver.findElement(MobileBy.AndroidUIAutomator(     //“ new UiScrollable(new UiSelector()。resourceIdMatches(\” // android.widget.NumberPicker [@ index ='0'] \“)。flingForward()”));

daypicker.sendKeys("12"));  (for sample 12.Jan 1964) 


here is the error text resp. log which  I got in inteliJ:






org.openqa.selenium.UnsupportedCommandException: Could not parse UiSelector argument: unclosed paren in expression
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'MYHOST', ip: '192.168.227.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.2'
Driver info: io.appium.java_client.AppiumDriver
Capabilities {MobileCapabilityType.FULL_RESET: true, PlatformVersion: 9.0, app: D:\08_OSCA\APKs\aOS\1.0_115..., appActivity: net.myAPP.view...., appPackage: net.myAPP.int, appWaitActivity: net.myAPP.*, appWaitPackage: net.myAPP.int, databaseEnabled: false, desired: {MobileCapabilityType.FULL_RESET: true, PlatformVersion: 9.0, app: D:\08_OSCA\APKs\aOS\1.0_115..., appWaitActivity: net.myAPP.*, deviceName: Huawei Mate20, language: en, locale: US, noReset: false, platformName: android}, deviceManufacturer: samsung, deviceModel: SM-G950F, deviceName: ce031713636588a20c, deviceScreenSize: 1440x2960, deviceUDID: ce031713636588a20c, javascriptEnabled: true, language: en, locale: US, locationContextEnabled: false, networkConnectionEnabled: true, noReset: false, platform: LINUX, platformName: LINUX, platformVersion: 9, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 7ce983d2-0d18-4627-8a24-7b7945a5fdfc
*** Element info: {Using=-android uiautomator, value=new UiScrollable(new UiSelector().resourceIdMatches("//android.widget.NumberPicker[@index='0']").flingForward()}

    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at io.appium.java_client.MobileBy.findElement(MobileBy.java:63)
    at io.appium.java_client.MobileBy$ByAndroidUIAutomator.findElement(MobileBy.java:282)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at screens.RegistrationScreen.select_Day(RegistrationScreen.java:138)
    at tests.registration.Register_Tests.TC_2292_RegisterNewUser(Register_Tests.java:120)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
    at org.testng.TestNG.runSuites(TestNG.java:1049)
    at org.testng.TestNG.run(TestNG.java:1017)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)

感谢任何支持

1 个答案:

答案 0 :(得分:0)

通过查看异常,给定元素不具有scrollable = true。

相反,您可以使用以下代码设置日期

driver.findElement(By.xpath("//android.widget.NumberPicker[@index='0']//android.widget.EditText[@index=1]")).sendKeys("12");

driver.findElement(By.xpath("//android.widget.NumberPicker[@index='1']//android.widget.EditText[@index=1]")).sendKeys("Jan");

driver.findElement(By.xpath("//android.widget.NumberPicker[@index='2']//android.widget.EditText[@index=1]")).sendKeys("2019");

driver.findElement(By.id("android:id/button1")).click();

尝试