没有这样的元素异常(警告:服务器没有提供任何堆栈跟踪信息)

时间:2016-06-20 08:55:13

标签: java selenium intellij-15

我学习自动化,我的java代码中有例外。使用Intellij IDEA

public static void main(String[] args) throws MalformedURLException, InterruptedException {

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("deviceName", "84B7N16401000731");
    caps.setCapability("platformName", "Android");
    caps.setCapability("app", "C:\\Appium\\node_modules\\appium\\build\\unlock_apk\\unlock_apk-debug.apk");
    Thread.sleep(5000);
 AndroidDriver driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);

    driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Apps\")").click();
    driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Speech Morphing\")").click();

    driver.quit();
}

并且有异常消息

  

&#34; C:\ Program Files \ Java \ jdk1.8.0_91 \ bin \ java&#34; -Didea.launcher.port = 7535&#34; -Didea.launcher.bin.path = C:\ Program Files(x86)\ JetBrains \ IntelliJ IDEA Community Edition 2016.1.3 \ bin&#34; -Dfile.encoding = UTF-8 -classpath&#34; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ charsets.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ deploy.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ access-bridge-64.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ cldrdata.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ dnsns.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ jaccess。 jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ jfxrt.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ localedata.jar; C: \ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ nashorn.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ sunec.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ sunjce_provider.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ sunmscapi.jar; C:\ Program Files \ Java \ jdk1。 8.0_91 \ jre \ lib \ ext \ sunpkcs11.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ ext \ zipfs.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ javaws.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ jce.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ jfr.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ jfxswt.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ jsse.jar; C: \ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ management-agent.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ plugin.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ resources.jar; C:\ Program Files \ Java \ jdk1.8.0_91 \ jre \ lib \ rt.jar; C:\ Speechmorphing_Auto \ build \ classes \ main; C:\ Users \ amro.gradle \缓存\模块-2 \文件-2.1 \ io.appium \ Java的客户机\ 4.0.0 \ b73316f27bb70d60081429c768cf09a09f6eeece \ Java的客户机 - 4.0.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \的junit \的junit \ 4.12 \ 2973d150c0dc1fefe998f834810d68f278ea58ec \的junit-4.12.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ com.google.code.gson \ GSON \ 2.6.2 \ f1bc476cc167b18e66c297df599b2377131a8947 \ GSON-2.6.2.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.seleniumhq.selenium \硒-java的\ 2.53.0 \ 645a24b52c9e5704e900ac755b5800352e981af7 \硒-java-2.53.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.apache.httpcom ponents \ HttpClient的\ 4.5.2 \ 733db77aa8d9b2d68015189df76ab06304406e50 \ HttpClient的-4.5.2.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ com.google.guava \番石榴\ 19.0 \ 6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9 \番石榴-19.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ CGLIB \ CGLIB \ 3.2.1 \ e5358fe643ab732ca07b2c0a7bbdd47719cca166 \ CGLIB的3.2.1.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \公地验证\公地验证\ 1.5.0 \ 26b98c21975c5caf6bf34bacdeb7183be7a65970 \公地验证-1.5.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.apache.commons \公地lang3 \ 3.4 \ 5fe28b9518e58819180a43a850fbc0dd24b7c050 \公地lang3-3.4.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.hamcrest \ hamcrest -core \ 1.3 \ 42a25dc3219429f0e5d060061f71acb49bf010a0 \ hamcrest核-1.3.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.seleniumhq.selenium \硒 - 铬 - 驱动\ 2.53.0 \ 7541a3948c3fb31122ee9633731e8103f3292b0a \硒 - 铬 - 驾驶员2.53.0.jar; C:\用户\ amro.gradle \缓存\ MODU LES-2 \文件-2.1 \ org.seleniumhq.selenium \硒边驱动器\ 2.53.0 \ 9f3da0dfa620ae8cd71afacfdd6ddae5028ce1ea \硒 - 边缘驾驶员2.53.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.seleniumhq.selenium \硒 - 火狐驱动\ 2.53.0 \ 5dc655b1999898d2fc3791c649b7355d98629a69 \硒 - 火狐驱动-2.53.0.jar; C:\用户\ amro.gradle \缓存\模块 - 2 \文件-2.1 \ org.seleniumhq.selenium \硒 - 即驱动器\ 2.53.0 \ 27b703e9fba9c0f636109cf4bd697c1f208ac825 \硒 - 即驱动-2.53.0.jar; C:\用户\ amro.gradle \缓存\模块-2- \文件-2.1 \ org.seleniumhq.selenium \硒 - 狩猎驱动\ 2.53.0 \ c80224258a8b702c99f2d7b3847ce89dc1bcd2bd \硒 - 狩猎驱动-2.53.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.seleniumhq.selenium \含硒载体\ 2.53.0 \ 3706aa8a696d1b7938365a41ee7ca46309a0b2d \含硒载体-2.53.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \有机.seleniumhq.selenium \硒腿-RC \ 2.53.0 \ bdabcf672449c588913ae32973dd8f7d54f510de \硒腿-RC-2.53.0.jar; C:\用户小号\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.apache.httpcomponents \的HttpCore \ 4.4.4 \ b31526a230871fbe285fbcbe2813f9c0839ae9b0 \的HttpCore-4.4.4.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \共享记录\共享记录\ 1.2 \ 4bfc12adfe4842bf07b657f0369c4cb522955686 \共享记录-1.2.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \公地编解码器\公地编解码器\ 1.9 \ 9ce04e34240f674bc72680f8b843b1457383161a \公地编解码器-1.9.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.ow2.asm \ ASM \ 5.0.3 \ dcc2193db20e19e1feca8b1240dbbc4e190824fa \ ASM -5.0.3.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.apache.ant \蚂蚁\ 1.9.4 \ 6d473e8653d952045f550f4ef225a9591b79094a \蚂蚁1.9.4.jar; C: \用户\ amro.gradle \缓存\模块-2 \文件-2.1 \公地BeanUtils的\公地BeanUtils的\ 1.9.2 \ 7a87d845ad3a155297e8f67d9008f4c1e5656b71 \公地BeanUtils的-1.9.2.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \公地消化器\公地消化器\ 1.8.1 \ 3dec9b9c7ea9342d4dbe8c38560080d85b44a015 \公地消化器-1.8.1.ja R; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \公地集合\公地集合\ 3.2.2 \ 8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5 \公地集合-3.2.2.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.seleniumhq.selenium \硒 - 远程驱动器\ 2.53.0 \ eb76ed037ba5a7c11cce11effd0e2175056905ac \硒 - 远程驾驶员2.53.0.jar; C:\用户\ AMRO .gradle \缓存\模块-2 \文件-2.1 \公地-IO \公地-IO \ 2.4 \ b1b6ea3b7e4aa4f492509a4952029cd8e48019ad \公地-IO-2.4.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件 - 2.1 \ org.apache.commons \公地EXEC \ 1.3 \ 8dfb9facd0830a27b1b5f29f84593f0aeee7773b \公地EXEC-1.3.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ net.java.dev.jna \ JNA \ 4.1.0 \ 1c12d070e602efd8021891cdd7fd18bc129372d4 \ JNA-4.1.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ net.java.dev.jna \ JNA平台\ 4.1。 0 \ 23457ad1cf75c2c16763330de5565a0e67b4bc0a \ JNA平台-4.1.0.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ io.netty \网状\ 3.5.7.Final \ 811465e6dfc89d7c78d21de 6a9747b6046cb5403 \网状-3.5.7.Final.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ org.apache.ant \蚂蚁发射\ 1.9.4 \ 334b62cb4be0432769679e8b94e83f8fd5ed395c \蚂蚁发射-1.9.4.jar; C:\用户\ amro.gradle \缓存\模块-2 \文件-2.1 \ CGLIB \ CGLIB的节点p \ 2.1_3 \ 58d3be5953547c0019e5704d6ed4ffda3b0c7c66 \ CGLIB的节点p-2.1_3.jar; C:\用户\ amro.gradle \ _caches \ modules-2 \ files-2.1 \ org.seleniumhq.selenium \ selenium-api \ 2.53.0 \ a6105ad5c43dcc02c1cf87250111b0a7f1a7c2e6 \ selenium-api-2.53.0.jar; C:\ Program Files(x86)\ JetBrains \ IntelliJ IDEA社区版2016.1.3 \ lib \ idea_rt.jar&#34; com.intellij.rt.execution.application.AppMain Main   线程&#34; main&#34;中的例外情况org.openqa.selenium.NoSuchElementException:使用给定的搜索参数无法在页面上找到元素。 (警告:服务器未提供任何堆栈跟踪信息)   命令持续时间或超时:3.26秒   有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html   构建信息:版本:&#39; 2.53.0&#39;,修订版:&#39; 35ae25b1534ae328c771e0856c93e187490ca824&#39;,时间:&#39; 2016-03-15 10:43:46&#39;   系统信息:主持人:&#39; DESKTOP-LHDBICT&#39;,ip:&#39; 169.254.29.190&#39;,os.name:&#39; Windows 10&#39;,os.arch:&# 39; amd64&#39;,os.version:&#39; 10.0&#39;,java.version:&#39; 1.8.0_91&#39;   驱动程序信息:io.appium.java_client.android.AndroidDriver   功能[{app = C:\ Appium \ node_modules \ appium \ build \ unlock_apk \ unlock_apk-debug.apk,networkConnectionEnabled = true,warnings = {},databaseEnabled = false,deviceName = 84B7N16401000731,platform = LINUX,desired = {app = C:\ Appium \ node_modules \ appium \ build \ unlock_apk \ unlock_apk-debug.apk,platformName = Android,deviceName = 84B7N16401000731},platformVersion = 6.0.1,webStorageEnabled = false,locationContextEnabled = false,browserName = Android,takesScreenshot = true, javascriptEnabled = true,platformName = Android}]   会议ID:51cac0c2-8741-4fa6-b5a6-7d0e807f8228   ***元素信息:{Using = -android uiautomator,value = new UiSelector()。description(&#34; Apps&#34;)}       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)       at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)       at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)       在io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)       在org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)       at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:67)       at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)       在io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)       在io.appium.java_client.android.AndroidDriver.findElementByAndroidUIAutomator(AndroidDriver.java:468)       在Main.main(Main.java:21)       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)       在com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

     

使用退出代码1完成处理

1 个答案:

答案 0 :(得分:0)

&#34;使用给定的搜索参数无法在页面上找到元素&#34;这意味着您用于在应用上找到元素的ID不正确。 您在运行测试时是否启动了应用程序?