我正在尝试自动化Selendroid的测试应用程序。
有混合视图。
即使更改了上下文,我也无法在WebView上执行任何活动。
测试应用程序:来自Selendroid UI的/selendroid-test-app-0.17.0.apk
Appium版本:1.6.5
脚本: driver.findElementById(" io.selendroid.testapp:ID / buttonStartWebview&#34)。单击();
Set<String> views = driver.getContextHandles();
Iterator it=views.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
driver.context("WEBVIEW_io.selendroid.testapp");
Thread.sleep(3000);
System.out.println("Current view is"+driver.getContext());
System.out.println(driver.getPageSource());
driver.findElement(By.xpath("//*[@id='name_input']")).sendKeys("test");;
Eclipse日志
[TestNG]正在运行:
NATIVE_APP WEBVIEW_io.selendroid.testapp 当前视图是WWEVIEW_io.selendroid.testapp
<html><head><title>Say Hello Demo</title></head><body>Hello, can you please tell me your name?<form name="myform" action="http://localhost:4450/sayhello" method="get"><div align="center"><br><br><input type="text" id="name_input" name="name" size="25" value="Enter your name here!"><br><p>Prefered Car:<br><select name="car"><option value="volvo">Volvo</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option></select></p><br><input type="submit" value="Send me your name!"><br></div></form><iframe name="chromedriver dummy frame" src="about:blank"></iframe></body></html>
&#13;
失败:f org.openqa.selenium.ElementNotVisibleException:元素不可见 (会话信息:webview = 30.0.0.0) (驱动程序信息:chromedriver = 2.28.455520(cc17746adff54984afff480136733114c6b3704b),platform = Windows NT 10.0.10586 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:1.04秒 构建信息:版本:&#39; 2.53.1&#39;,修订版:&#39; a36b8b1cd5757287168e54b817830adce9b0158d&#39;,时间:&#39; 2016-06-30 19:26:09&#39; 系统信息:主机:&#39; INHYIZLP06494&#39;,ip:&#39; 10.7.60.141&#39;,os.name:&#39; Windows 10&#39;,os.arch:&#39; amd64&#39;,os.version:&#39; 10.0&#39;,java.version:&#39; 1.8.0_141&#39; 驱动程序信息:io.appium.java_client.android.AndroidDriver 功能[{app = D:\ RnD \ WorkspaceDev \ Appium \ AUT \ selendroid-test-app-0.17.0.apk,appPackage = io.selendroid.testapp,deviceScreenSize = 1280x720,networkConnectionEnabled = true,warnings = {},appWaitPackage = io.selendroid.testapp,appWaitActivity = io.selendroid.testapp.HomeScreenActivity,databaseEnabled = false,deviceName = emulator-5554,platform = LINUX,deviceUDID = emulator-5554,appActivity = io.selendroid.testapp.HomeScreenActivity,desired = { app = D:\ RnD \ WorkspaceDev \ Appium \ AUT \ selendroid-test-app-0.17.0.apk,platformName = Android,deviceName = emulator-5554},platformVersion = 4.4.2,webStorageEnabled = false,locationContextEnabled = false, takesScreenshot = true,javascriptEnabled = true,deviceModel = SM-G900F,platformName = Android,deviceManufacturer = samsung}] 会话ID:9b4cd26a-1d77-4087-8ce9-d87fbdef24e0 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 在io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) 在io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) 在org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327) at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:33) at io.appium.java_client.MobileElement.execute(MobileElement.java:1) 在io.appium.java_client.android.AndroidElement.execute(AndroidElement.java:1) 在org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:122) 在HybridApp.SelendroidTestHybrid.f(SelendroidTestHybrid.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) 在org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) 在org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) 在org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) 在org.testng.TestRunner.privateRun(TestRunner.java:756) 在org.testng.TestRunner.run(TestRunner.java:610) 在org.testng.SuiteRunner.runTest(SuiteRunner.java:387) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) 在org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) 在org.testng.SuiteRunner.run(SuiteRunner.java:289) 在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) 在org.testng.TestNG.runSuites(TestNG.java:1133) 在org.testng.TestNG.run(TestNG.java:1104) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236) 在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)