我在测试ios的appium时遇到此错误:
> Exception in thread "main" org.openqa.selenium.WebDriverException: An > error occurred while executing user supplied JavaScript. (WARNING: The > server did not provide any stacktrace information) Command duration or > timeout: 5.15 seconds Build info: version: '2.52.0', revision: > '4c2593c', time: '2016-02-11 19:03:33' System info: host: > 'users-iMac.local', ip: '192.168.1.16', os.name: 'Mac OS X', os.arch: > 'x86_64', os.version: '10.10.5', java.version: '1.7.0_80' Session ID: > cdcaf9fa-3530-4b09-8bca-c30c42d6c29e Driver info: > io.appium.java_client.ios.IOSDriver Capabilities > [{platformVersion=9.2, platform=MAC, databaseEnabled=false, > javascriptEnabled=true, platformName=iOS, deviceName=iPad 2, > browserName=iOS, webStorageEnabled=false, > bundleId=com.InovaSquad.Artinove, networkConnectionEnabled=false, > desired={platformVersion=9.2, deviceName=iPad 2, platformName=iOS, > bundleId=com.InovaSquad.Artinove}, locationContextEnabled=false, > warnings={}, takesScreenshot=true}] at > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at > org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) > at > org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) > at > org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) > at > io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) > at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at > io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1) at > org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327) > at > io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:44) > at io.appium.java_client.MobileElement.execute(MobileElement.java:1) > at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1) at > org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:122) > at test1.FirstTest.main(FirstTest.java:49)
FirstTest.java
package test1;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
/*
@author:Hajar
11/03/2016
*/
public class FirstTest {
public static AppiumDriver dr;
public static void main(String[] args)
throws MalformedURLException, InterruptedException{
DesiredCapabilities capabilities = new DesiredCapabilities();
// Platform de l'emulateur
capabilities.setCapability("platformName","iOS");
// La version de l'emulateur
capabilities.setCapability("platformVersion", "9.2");
// le nom de l'emulateur
capabilities.setCapability("deviceName","iPad 2");
capabilities.setCapability("bundleId","com.InovaSquad.Artinove");
dr=new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
dr.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[2]/UIAWebView[1]/UIALink[2]/UIAStaticText[1]")).click();
dr.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[2]/UIAWebView[1]/UIATextField[1]")).sendKeys("ggg");
}
}
服务器日志:
info:[debug]向乐器发送命令: au.getElementByIndexPath(' / 0/0/1/0/1')info:[IOS_SYSLOG_ROW] 3月18日 15:39:46 users-iMac mstreamd [70568] :(注意)PS:媒体流守护进程 停止。 info:[IOS_SYSLOG_ROW] Mar 18 15:39:46 users-iMac mstreamd [70568] :(注)AS :: Shared Streams守护程序已关闭。信息:[IOS_SYSLOG_ROW] 3月18日 15:39:46 users-iMac mstreamd [70568] :(警告)mstreamd:mstreamd 关闭。
info:[debug] [INST] 2016-03-18 15:39:46 +0000调试:得到新命令 7来自乐器:au.getElementByIndexPath(' / 0/0/1/0/1')信息: [调试] [INST] 2016-03-18 15:39:46 +0000调试:评估 au.getElementByIndexPath(' / 0/0/1/0/1&#39)
info:[debug]收到的套接字数据(38字节)
info:[debug]路由的套接字数据。 info:[debug]得到的结果 工具:{"状态":0,"价值":{"元素":" 1"}}信息:[debug] 成功回应客户: {"状态":0,"值" {" ELEMENT":" 1"}"的sessionId&#34 ;: " d860df3d-b4be-46a5-8ee4-de67f7d04e55"} 信息:< - POST / wd / hub / session / d860df3d-b4be-46a5-8ee4-de67f7d04e55 / element 200 2387.424 ms - 87 {" status":0," value":{" ELEMENT":" 1"}," sessionId& #34;:" d860df3d-b4be-46a5-8ee4-de67f7d04e55"}
info: - > POST / WD /集线器/会话/ d860df3d-b4be-46a5-8ee4-de67f7d04e55 /元件/ 1 /值 {" id":" 1","值":[" ggg"]}信息:[debug]将命令推送到appium 工作队列:" au.getElement(' 1')。setValueByType(' ggg')"信息:[调试] 向仪器发送命令: au.getElement(' 1')。setValueByType(' ggg')info:[debug] [INST] 2016-03-18 15:39:46 +0000调试:评测完成信息:[debug] [INST] 2016-03-18 15:39:46 +0000调试:回复:info:[debug] [INST] 2016-03-18 15:39:46 +0000调试:运行系统命令#8: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js / tmp / instruments_sock 2,{" status":0," value":{" ELEMENT":" 1"}} ...
info:[debug] [INST] 2016-03-18 15:39:47 +0000 Debug:获得新命令 8来自乐器:au.getElement(' 1')。setValueByType(' ggg')
info:[debug] [INST] 2016-03-18 15:39:47 +0000调试:评估 au.getElement(' 1')。setValueByType(' ggg')info:[debug] [INST] 2016-03-18 15:39:47 +0000调试:未找到键盘。攻击制作 可见。 info:[debug] [INST] 2016-03-18 15:39:47 +0000 Debug: target.frontMostApp()。元素()[0] .elements()[1] .elements()[0] .elements()[1] .tap()
info:[IOS_SYSLOG_ROW] Mar 18 15:39:47 users-iMac断言[70583]: 断言失败:14F27 13C75:断言+ 13207 [792516D1-991E-36EE-8454-16F8220758D6]:0x1 info:[debug] [INST] 2016-03-18 15:39:48 +0000调试:仍未找到键盘。窃听 再次让人眼前一亮。
info:[debug] [INST] 2016-03-18 15:39:48 +0000调试: target.frontMostApp()。元素()[0] .elements()[1] .elements()[0] .elements()[1] .tap()
info:[IOS_SYSLOG_ROW] 3月18日15:39:50 ---最后一条消息重复3 时代---信息:[IOS_SYSLOG_ROW] 3月18日15:39:50用户-iMac Artinove [70619]:mousedown停止事件
info:[IOS_SYSLOG_ROW] Mar 18 15:39:50 users-iMac断言[70583]: 断言失败:14F27 13C75:断言+ 13207 [792516D1-991E-36EE-8454-16F8220758D6]:0x1
info:[debug] [INST] 2016-03-18 15:39:50 +0000调试: target.frontMostApp()键盘()typeString(" G&#34)。
info:[debug] [INST] 2016-03-18 15:39:51 +0000调试: target.frontMostApp()。键盘()无法点按'
info:[debug] [INST] 2016-03-18 15:39:51 +0000调试:输入错误 ' g':VerboseError:target.frontMostApp()。键盘()无法点按'
info:[IOS_SYSLOG_ROW] 3月18日15:39:51 ---最后一条消息重复1 时间---信息:[IOS_SYSLOG_ROW] 3月18日15:39:51用户-iMac kbd [70636]:表格丢弃:101
info:[debug] [INST] 2016-03-18 15:39:51 +0000 Debug:重试... info:[debug] [INST] 2016-03-18 15:39:51 +0000 Debug: target.frontMostApp()键盘()typeString(" G&#34)。
info:[debug] [INST] 2016-03-18 15:39:52 +0000调试: target.frontMostApp()。键盘()无法点按'
info:[debug]接收到套接字数据(76字节)
非常感谢任何帮助!