环境信息:
Appium(1.4.3)+Android(5.0)
java-client (3.0.0)
最近在做 APP 的测试,automationName 设置为Selendroid, 出现了定位到元素,但是点击元素报 An unknown server-side error
By specfied_locator = By.cssSelector(".playgo_list.days_panel>li:nth-child(2)");
setWebView0Context(driver, "NATIVE_APP");
setWebView0Context(driver, "WEBVIEW_0");
waitForClickabilityOf(specfied_locator);
System.out.println(driver.findElement(specfied_locator).getText());
driver.findElement(specfied_locator).click();
能定位到该元素,而且能获取元素的 text ("2 日"),但是 click 的时候报错如下:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 304 milliseconds
Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: 'DST63159', ip: '10.32.20.128', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_60'
Session ID: f7ccd806-edda-bf47-7744-1554dc53b8a2
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{automationName=selendroid, platform=ANDROID, acceptSslCerts=true, javascriptEnabled=true, browserName=selendroid, appActivity=.home.CtripSplashActivity, networkConnectionEnabled=true, keystorePassword=CtripAndroid, rotatable=true, desired={automationName=Selendroid, app=E:\Travel\AppiumDemo\apps\product_1708167.apk,platformName=Android, deviceName=668557ed, appActivity=.home.SplashActivity, device=Android,, useKeystore=true, appPackage=test.android.view}, useKeystore=true, appPackage=ctrip.android.view, version=0.15.0, platformVersion=21, deviceName=668557ed, platformName=android, handlesAlerts=true, device=Android,, 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:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:27)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.android.AndroidElement.execute(AndroidElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:80)
at pages.TravelDetailPage.tochooseDate(TravelDetailPage.java:42)
at scenarios.GroupTourTest.TestStartDate(GroupTourTest.java:46)
log 日志:
info: [debug] Available contexts: WEBVIEW_0,NATIVE_APP
info: [debug] ["WEBVIEW_ctrip.android.view"]
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/window_handles","method":"GET"}
info: [debug] Available contexts: ["WEBVIEW_0","NATIVE_APP"]
info: [debug] Responding to client with success: {"status":0,"value":["WEBVIEW_0","NATIVE_APP"],"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7"}
info: <-- GET /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/contexts 200512.937 ms - 98 {"status":0,"value":["WEBVIEW_0","NATIVE_APP"],"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7"}
info: --> POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/context {"name":"WEBVIEW_0"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: D:\allsdk\platform-tools\adb.exe -s 668557ed shell "cat /proc/net/unix"
info: [debug] WEBVIEW_20459 mapped to pid 20459
info: [debug] Getting process name for webview
info: [debug] executing cmd: D:\allsdk\platform-tools\adb.exe -s 668557ed shell "ps"
info: [debug] Parsed pid: 20459 pkg: ctrip.android.view
info: [debug] from: u0_a2470,20459,326,2388404,295048,ffffffff,00000000,S,ctrip.android.view
info: [debug] returning process name: ctrip.android.view
info: [debug] Available contexts: WEBVIEW_0,NATIVE_APP
info: [debug] ["WEBVIEW_ctrip.android.view"]
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/window_handles","method":"GET"}
info: [debug] Available contexts: ["WEBVIEW_0","NATIVE_APP"]
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/context","method":"POST","json":{
"name":"WEBVIEW_0"}}
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7"}
info: <-- POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/context 200428.880 ms - 76 {"status":0,"value":null,"sessionId":"8dd54ef5-ff4b-713d-6944-64
44645e99a7"}
info: --> POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element {"using":"css selector","value":".playgo_list.days_panel>li:nth-child(2)"}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element","method":"POST","json":{
"using":"css selector","value":".playgo_list.days_panel>li:nth-child(2)"}}
info: [debug] Proxied response received with status 200: {"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7","status":0,"value":{"ELEMENT":":wdc:1449713052433"}
}
info: <-- POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element 20097.199 ms - 104
info: --> GET /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/displayed {}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/di
splayed","method":"GET"}
info: [debug] Proxied response received with status 200: {"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7","status":0,"value":true}
info: <-- GET /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/displayed 200 122.695 ms - 76
info: --> GET /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/enabled {}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/en
abled","method":"GET"}
info: [debug] Proxied response received with status 200: {"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7","status":0,"value":true}
info: <-- GET /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/enabled 200 56.363 ms - 76
info: --> POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element {"using":"css selector","value":".playgo_list.days_panel>li:nth-child(2)"}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element","method":"POST","json":{
"using":"css selector","value":".playgo_list.days_panel>li:nth-child(2)"}}
info: [debug] Proxied response received with status 200: {"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7","status":0,"value":{"ELEMENT":":wdc:1449713052433"}
}
info: <-- POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element 20072.969 ms - 104
info: --> POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/click {"id":":wdc:1449713052433"}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/cl
ick","method":"POST","json":{"id":":wdc:1449713052433"}}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue"
:"CATCH_ALL: java.lang.NumberFormatException: Invalid int: \"61.1875\"\n\tat
java.lang.Integer.invalidInt(Integer.java:138)\n\tat java.lang.Integer.parse(Integer.java:410)\n\tat
java.lang.Integer.parseInt(Integer.java:367)\n\tat
java.lang.Integer.parseInt(Integer.java:334)\n\tat
io.selendroid.server.model.AndroidWebElement.getCenterCoordinates(AndroidWebElement.java:233)\n\tat
io.selendroid.server.model.AndroidWebElement.click(AndroidWebElement.java:249)\n\tat
io.selendroid.server.handler.ClickElement.safeHandle(ClickElement.java:36)\n\tat
io.selendroid.server.handler.SafeRequestHandler.handle(SafeRequestHandler.java:87)\n\tat
io.selendroid.server.AndroidServlet.handleRequest(AndroidServlet.java:264)\n\tat
io.selendroid.server.common.BaseServlet.handleHttpRequest(BaseServlet.java:67)\n\tat
io.selendroid.server.common.http.ServerHandler.channelRead(ServerHandler.java:53)\n\tat
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)\n\tat
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)\n\tat
io.netty.handler.traffic.AbstractTrafficShapingHandler.channelRead(AbstractTrafficShapingHandler.java:223)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)\n\tat
io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)\n\tat
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)\n\tat io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:148)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)\n\tat
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:430)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:384)\n\tat
io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)\n\tat
io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)\n\tat io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)\n\tat java.lang.Thread.run(Thread.java:818)\n"},"sessionId":"8dd54ef5-ff4b-713d-6944-6444645e99a7"}
info: <-- POST /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7/element/%3Awdc%3A1449713052433/click 500 250.163 ms - 3111
info: --> DELETE /wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7 {}
info: Shutting down appium session
info: [debug] Stopping selendroid server
info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8dd54ef5-ff4b-713d-6944-6444645e99a7","method":"DELETE"}
info: [debug] executing cmd: D:\allsdk\platform-tools\adb.exe -s 668557ed shell "am force-stop ctrip.android.view"
已经排查,页面加载完毕,而且元素只有一个,现在没有好的解决方案
这个问题已经困扰一个礼拜了,绝不是伸手党 ,恳请大神帮忙看下!!!
哪位大神能帮忙解决下这个问题