我想点击退出按钮。我尝试过以下操作来执行点击操作
使用Tap
WebElement logOut = driver.findElementByName("Log out");
TouchAction act = new TouchAction(driver);
act.tap(logOut, 1, 1);
单击
WebElement logOut = driver.findElementByName("Log out");
logOut.click();
按
TouchAction act = new TouchAction(driver);
act.press(logOut).perform()
按其给予
An unknown server-side error occurred while processing the command.
也试过
MobileElement logout = (MobileElement) driver.findElementByName("Log out");
logout.tap(1, 10);
这会产生同样未知的服务器端错误
如果我在任何地方做错了,请告诉我。
提前致谢。
这是服务器日志
> info: [debug] [BOOTSTRAP] [debug] Finding Log out using NAME with the contextId: multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=Log out, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"2"}}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"2"},"sessionId":"ad4afb54-6f6d-4a39-bb60-49e4cbbcc4bc"}
> info: <-- POST /wd/hub/session/ad4afb54-6f6d-4a39-bb60-49e4cbbcc4bc/element 200 44.615 ms - 87 {"status":0,"value":{"ELEMENT":"2"},"sessionId":"ad4afb54-6f6d-4a39-bb60-49e4cbbcc4bc"}
> info: --> POST /wd/hub/session/ad4afb54-6f6d-4a39-bb60-49e4cbbcc4bc/touch/perform {"actions":[{"action":"press","options":{"element":"2"}},{"action":"wait","options":{"ms":250}},{"action":"release","options":{}}]}
> info: [debug] Pushing command to appium work queue: ["element:getLocation",{"elementId":"2"}]
> info: [debug] Pushing command to appium work queue: ["element:getSize",{"elementId":"2"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"2"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"x":-256,"y":932}}
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"2"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: getSize
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"width":240,"height":81}}
> info: [debug] Pushing command to appium work queue: ["element:getLocation",{"elementId":"2"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"2"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"x":-256,"y":932}}
> info: [debug] Pushing command to appium work queue: ["element:getSize",{"elementId":"2"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"2"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: getSize
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"width":240,"height":81}}
> info: [debug] Pushing command to appium work queue: ["element:touchDown",{"elementId":"2","x":-136,"y":972.5}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"elementId":"2","x":-136,"y":972.5}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: touchDown
> info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? true x: -136, y: 972
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Failed to execute touch event"}
> info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Failed to execute touch event"},"sessionId":"ad4afb54-6f6d-4a39-bb60-49e4cbbcc4bc"}
> info: <-- POST /wd/hub/session/ad4afb54-6f6d-4a39-bb60-49e4cbbcc4bc/touch/perform 500 211.167 ms - 198
> info: [debug] Didn't get a new command in 60 secs, shutting down...
> info: Shutting down appium session
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: C:\Users\fission\AppData\Local\Android\android-sdk\platform-tools\adb.exe -s f547bbb6 shell "input keyevent 3"
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
> info: [debug] [BOOTSTRAP] [debug] Closed client connection
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
> info: [debug] [UIAUTOMATOR STDOUT] Time: 82.744
> info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: shortMsg=java.lang.SecurityException
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: longMsg=Permission Denial: getIntentSender() from pid=21860, uid=2000, (need uid=1000) is not allowed to send as package android
答案 0 :(得分:0)
试试这个
List<WebElement> list = driver.findElementByName("Log out");
for (int 1=0;1<list.size();i++){
System.out.println("clicked on "+list.get(i).getAttribute("name"))
}
这将给你所有元素索引号及其名称。您可以从中点击特定索引,例如: - list.get(6).click();
答案 1 :(得分:0)
如果您的点击事件无效,那么您的开发者可能必须使用某些api,例如 patlab 而非点击事件..
你应该咨询你的开发人员他/她是否使用过像aplab一样的api
如果是,那么请向开发人员询问事件名称,然后使用jquery
进行触发