我在移动Native App中滚动时遇到问题, 我在用 : Java语言 Java客户端1.7.0 appium节点1.13.0 操作系统版本Android AND Appium驱动程序
,并尝试在进入“个人资料”页面后滚动,但出现了一些应用崩溃的情况。
我正在使用以下Methode进行滚动:
public void scrollDown() {
Dimension dimension = driver.manage().window().getSize();
// System.out.println("Dimension value = "+dimension);
Double scrollHeightStart = dimension.getHeight() * 0.5;
int scrollStart = scrollHeightStart.intValue();
// System.out.println("Screen Height start Value="+scrollHeightStart);
Double scrollHeightEnd = dimension.getHeight() * 0.2;
int scrollEnd = scrollHeightEnd.intValue();
// System.out.println("Scroll Start Value="+scrollHeightEnd);
TouchAction touch = new TouchAction((PerformsTouchActions) driver);
touch.press(PointOption.point(0, scrollStart))
.waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))
.moveTo(PointOption.point(0, scrollEnd))
.release()
.perform();
}
,但是通过调用Scroll方法运行脚本后,在Log中获得以下内容:
..........
.......
Juni 22, 2019 3:31:18 VORM. utilities.Helper startAppiumServer
INFO: utilities.Helper§§§§§§§§§§§§§§§§§§§§§§§ Start Appium Server §§§§§§§§§§§§§§§§§§§§§§§§§
startAppiumServer: Before Test done
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
Fatal Error: listen EADDRINUSE: address already in use 127.0.0.1:4723
at Server.setupListenHandle [as _listen2] (net.js:1270:14)
at listenInCluster (net.js:1318:12)
at doListen (net.js:1451:7)
at process._tickCallback (internal/process/next_tick.js:63:19)
Juni 22, 2019 3:31:31 VORM. io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/khazinehdarllo/.m2/repository/cglib/cglib/3.2.8/cglib-3.2.8.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Juni 22, 2019 3:31:31 VORM. utilities.Helper getmMthodName
INFO: utilities.Helper +++++++++++++++++++++ Start of Test Execution: Test Case TC_1296_ForgotPassword_FromChangePasswordScreen +++++++++++++++++++++++++++
Juni 22, 2019 3:31:37 VORM. screens.Welcome_Screen click_Login_Button
INFO: screens.Welcome_ScreenWELCOME Screen: Login Button clicked successfully (OK)
Juni 22, 2019 3:31:47 VORM. screens.Login_Screen enter_Valid_Email
INFO: screens.Login_ScreenREGISTRATION Screen: Email Field entered successfully (OK)
Juni 22, 2019 3:31:53 VORM. screens.Login_Screen enter_Valid_Password
INFO: screens.Login_ScreenREGISTRATION Screen: Password Field entered successfully (OK)
Juni 22, 2019 3:31:54 VORM. screens.Login_Screen select_remainLoggedIn_CheckBox
INFO: screens.Login_ScreenLOGIN Screen : RemainLoggedIn Checkbox selected successfully (OK)
Juni 22, 2019 3:31:55 VORM. screens.Login_Screen click_Login_Button
INFO: screens.Login_ScreenLOGIN Screen : Login Button clicked successfully (OK)
Juni 22, 2019 3:31:58 VORM. screens.SelectCity_Screen select_X
INFO: screens.SelectCity_ScreenSELECT CITY Screen : City X clicked successfully (OK)
Juni 22, 2019 3:32:01 VORM. screens.CommonObjects_InAll_Screen click_Profile_Icon
INFO: screens.CommonObjects_InAll_ScreenCOMMON OBJECT Profile Icon : Profile Icon clicked successfully (OK)
java.lang.NullPointerException
at utilities.PageActions.scrollDown(PageActions.java:308)
at testScripts.login.errorHandling.Login_ErrorHandling_No_FTU_Tests.TC_1296_ForgotPassword_FromChangePasswordScreen(Login_ErrorHandling_No_FTU_Tests.java:119)
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)
Juni 22, 2019 3:32:01 VORM. testScripts.BasicSetup stopApp
INFO: testScripts.BasicSetupDestroying Test Environment
Juni 22, 2019 3:32:01 VORM. testScripts.BasicSetup stopApp
INFO: testScripts.BasicSetupStop App
Juni 22, 2019 3:32:01 VORM. testScripts.BasicSetup stopApp
INFO: testScripts.BasicSetup ===================== End of Test Execution ===========================
===============================================
Default Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
Juni 22, 2019 3:32:02 VORM. testScripts.login.errorHandling.Login_ErrorHandling_No_FTU_Tests stopAppiumServer
INFO: testScripts.login.errorHandling.Login_ErrorHandling_No_FTU_TestsStop Appium Server
Juni 22, 2019 3:32:02 VORM. testScripts.login.errorHandling.Login_ErrorHandling_No_FTU_Tests stopAppiumServer
INFO: testScripts.login.errorHandling.Login_ErrorHandling_No_FTU_Tests===============================================
和.PageActions.scrollDown(PageActions.java:308)在方法scrollDown中的代码中:
尺寸标注= driver.manage()。window()。getSize();
我的假设是滚动视图不是从页面开头开始 所以我必须先切换到滚动视图布局,然后才能滚动
我在注册或登录屏幕中具有相同的视图,但是首先,当我单击scrolView中的任何其他点时,例如输入电子邮件或名称,然后可以向下滚动,但是在此窗口(配置文件)中,我不能
答案 0 :(得分:0)
通过使用UiAutomator和UiSelector滚动作品可以找到解决方案。
driver.findElement(MobileBy.AndroidUIAutomator(“ new UiScrollable(new UiSelector())。scrollIntoView(new UiSelector()。resourceId(\” <-your_resourceID->“));”));