无法在日历表单中滚动(日、月、年)
Posted
技术标签:
【中文标题】无法在日历表单中滚动(日、月、年)【英文标题】:Not able to scroll in the Calendar Form (for day , month, year) 【发布时间】:2019-10-18 04:02:20 【问题描述】:我正在尝试滚动生日日历以选择日、月和年。 每列都可以单独滚动。
我无法滚动并选择特定的出生日期,例如1964 年 1 月 12 日
我在得到生日日历后尝试过
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】:通过查看异常,给定元素没有 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();
试试这个
【讨论】:
谢谢,但它不起作用。它不会将值更改为 sendkeys 2019 年 1 月 12 日 它保持在 2019 年 6 月 3 日 但你是对的,第一列和第二列具有属性 Scrollable = False 但第三列是真的,它是否可能只滚动第三列,如果是这样,那么我可以要求开发人员将另一个也设置为 true 如果我只想滚动怎么样? 您可以通过多种方式做到这一点,也可以尝试其他方式以上是关于无法在日历表单中滚动(日、月、年)的主要内容,如果未能解决你的问题,请参考以下文章