Appium - 如何在iOS设备上设置地理位置?
元 :-
- iOS 模拟器设备 v10.3
- Appium java-client v5.0.0 BETA8
- 硒 v3.4.0
实际上,我正在尝试使用自动化来设置设备。我已经尝试了以下代码,该代码在设备上工作正常,同时在上抛出异常:GeoLocation
iOS
Appium
XCUITest
Android
iOS
import org.openqa.selenium.html5.Location;
AppiumServiceBuilder builder = new AppiumServiceBuilder().usingAnyFreePort().withAppiumJS("path/to/appium/main.js");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "XCUITest");
IOSDriver driver= new IOSDriver(builder, capabilities);
//Here this code working fine with AndroidDriver
Location location = new Location(latitude, longitude, altitude);
driver.setLocation(location);
例外:
org.openqa.selenium.WebDriverException: 方法尚未实现(警告:服务器未提供任何堆栈跟踪信息)
当我尝试使用JavascriptExecutor作为:
Map<String, String> args = new HashMap<String, String>();
args.put("address", "Address");
((JavascriptExecutor)webDriver).executeScript("mobile:setLocation", args);
例外:
org.openqa.selenium.UnsupportedCommandException: Unknown mobile command “setLocation”.仅滚动,滑动,捏合,双拍,两个手指点击,触摸并保持,点击,拖动FromToForDuration,选择PickerWheelValue,支持警报命令。(警告:服务器未提供任何堆栈跟踪信息)
当我尝试作为:
import org.openqa.selenium.remote.DriverCommand;
Map<String, String> args = new HashMap<String, String>();
args.put("location", "Address");
driver.execute(DriverCommand.SET_LOCATION, args);
例外:
org.openqa.selenium.WebDriverException: 方法尚未实现(警告:服务器未提供任何堆栈跟踪信息)
有没有办法继续使用appium?GeoLocation
iOS
应用日志:
[调试][JSONWP Proxy]获取状态为 200 的响应: “{\n \”value\“ : {\n \”state\“ : \”success\“,\n \”os\“ : {\n \”name\“ : \”iOS\“,\n \”version\“ : \”10.3.1\“\n },\n \”ios\“ : {\n \”simulatorVersion\“ : \”10.3.1\“,\n \”ip\“ : \”192.1 168.1.17\“\n },\n \”build\“ : {\n \”time\“ : \”Aug 29 2017 15:40:09\“\n }\n },\n \”sessionId\“ : \”10A97A93-D13A-4888-A536-0D62E0674A2B\“,\n \”status\“ : 0\n}”
[调试][XCUITest]WebDriverAgent 在 ip '192.168.1.17' [debug] [XCUITest] WebDriverAgent 在 16121 毫秒后成功启动 [debug] [BaseDriver] 事件 “wdaSessionAttempted” 记录于 1504013035278 (18:53:55 GMT+0530 (IST)) [debug] [XCUITest] 向 WDA [debug] [JSONWP Proxy] 发送 createSession 命令将 [POST /session] 代理 [POST /session] 到 [POST http://localhost:8100/session] with body: {“desiredCapabilities”:{“bundleId”:“com.example.apple-samplecode.UICatalog”,“arguments”:[],“environment”:{},“shouldWaitForQuiescence”:true,“shouldUseTestManagerForVisibilityDetection”:false,“maxTypingFrequency”:120,“shouldUseSingletonTestManager”:true}} [debug] [JSONWP Proxy] Got response with status 200: {“value”:{“sessionId”:“43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C”,“capabilities”:{“device”:“iphone”,“browserName”:“UICatalog”,“sdkVersion”:“10.3.1”,“CFBundleIdentifier”:“com.example.apple-samplecode.UICatalog”}},“sessionId”:“43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C”,“status”:0} [debug] [BaseDriver] Event 'wdaSessionStarted' 记录在 1504013038184 (18:53:58 GMT+0530 (IST)) [debug] [XCUITest] Found WDA 派生数据文件夹: '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs' [XCUITest] 将 '555' 权限设置为 '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Logs/Test/Attachments' folder [debug] [XCUITest] Found WDA derived data folder: '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-folfazwwukpzfkegdblpnfuwlvfn' [XCUITest] Set '555' permissions to '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-folfazwukpzfkegdblpnfuwlvfn/Logs/Test/Attachments' folder [debug] [BaseDriver]事件“wdaPermsAdjusted”记录在 1504013038192 (18:53:58 GMT+0530 (IST)) [调试] [BaseDriver] 事件“wdaStarted”记录于 1504013038193 (18:53:58 GMT+0530 (IST)) [调试] [XCUITest] 将初始方向设置为“纵向”[调试] [JSONWP 代理] 代理 [POST /方向] 到 [POST http://localhost:8100/session/43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C/orientation] with body: {“orientation”:“PORTRAIT”} [debug] [JSONWP Proxy] 得到状态为 200 的响应: {“value”:{},“sessionId”:“43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C”,“status”:0} [debug] [BaseDriver] 事件 “orientationSet” 记录在 1504013038453 (18:53:58 GMT+0530 (IST)) [Appium] 新的 XCUITestDriver 会话已成功创建,会话 6909c363-12a5-4a21-9298-c7f750ba7e09 添加到主会话列表 [调试] [BaseDriver] 事件 'newSessionStarted' 记录在 1504013038456 (18:53:58 GMT+0530 (IST)) [调试] [MJSONWP]响应客户端与驱动程序.createSession() 结果: {“webStorageEnabled”:false,“locationContextEnabled”:false,“browserName”:“”,“platform”:“MAC”,“javascriptEnabled”:true,“databaseEnabled”:false,“takesScreenshot”:true,“networkConnectionEnabled”:false,“app”:“src/test/resources/executor/UICatalog.app”,“maxTypingFrequency”:“120”,“newCommandTimeout”:0,“platformVersion”:“10.3”,“automationName”:“XCUITest”,“platformName”:“iOS”,“udid”:”0A41ECE4-6D03-4FEA-A82A-858FDBA6620E“,”deviceName“:”iPhone 6“} [HTTP] <-- POST /wd/hub/session 200 46915 ms - 512 [HTTP] --> GET /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09 {} [debug] [MJSONWP] Calling AppiumDriver.getSession() with args: [”6909c363-12a5-4a21-9298-c7f750ba7e09“] [debug] [XCUITest] 执行命令 'getSession' [debug] [JSONWP Proxy] 代理 [GET /] 到 [GET http://localhost:8100/session/43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C] 没有主体 [调试] [JSONWP 代理] 得到状态为 200 的响应: “{\n \”value\“ : {\n \”sessionId\“ : \”43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C\“,\n \”capabilities\“ : {\n \”device\“ : \”iphone\“,\n \”browserName\“ : \”UICatalog\“,\n
\”sdkVersion\“ : \”10.3.1\“,\n \”CFBundleIdentifier\“ : \”com.example.apple-samplecode.UICatalog\“\n }\n },\n \”sessionId\“ : \”43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C\“,\n \”status\“ : 0\n}” [XCUITest]合并 WDA caps over Appium caps for session detail response [debug] [MJSONWP] Response to client with driver.getSession() result: {“udid”:“”,“app”:“src/test/resources/executor/UICatalog.app”,“maxTypingFrequency”:120,“newCommandTimeout”:0,“platformVersion”:“10.3”,“automationName”:“XCUITest”,“platformName”:“iOS”,“deviceName”:“iPhone 6”,“device”:“iphone”,“browserName”:“UICatalog”,“sdkVersion”:“10.3.1”,“CFBundleIdentifier”:“com.example.apple-samplecode.UICatalog”} [HTTP] <-- GET /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09 200 110 ms - 406 [HTTP] --> GET /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09 {} [debug] [MJSONWP] Calling AppiumDriver.getSession() with args: [“6909c363-12a5-4a21-9298-c7f750ba7e09”] [debug] [XCUITest] 执行命令 'getSession' [debug] [JSONWP Proxy] 代理 [GET /] 到 [GET http://localhost:8100/session/43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C] 没有主体 [debug] [JSONWP 代理] 得到状态为 200 的响应: “{\n \”value\“ : {\n \”sessionId\“ : \”43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C\“,\n \”capabilities\“ : {\n \”device\“ : \”iphone\“,\n \”browserName\“ : \”UICatalog\“,\n
\”sdkVersion\“ : \”0“1 10.3.1\”,\n \“CFBundleIdentifier\” : \“com.example.apple-samplecode.UICatalog\”\n }\n },\n \“sessionId\” : \“43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C\”,\n \“status\” : 0\n}“ [XCUITest] 将 WDA 上限合并到 Appium 上限上以获取会话详细信息 response [debug] [MJSONWP] Response to client with driver.getSession() result: {“udid”:“”,“app”:“src/test/resources/executor/UICatalog.app”,“maxTypingFrequency”:120,“newCommandTimeout”:0,“platformVersion”:“10.3”,“automationName”:“XCUITest”,“platformName”:“iOS”,“deviceName”:“iPhone 6”,“device”:“iphone”,“browserName”:“UICatalog”,“sdkVersion”:“10.3.1”,“CFBundleIdentifier”:“com.example.apple-samplecode.UICatalog”} [HTTP] <-- GET /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09 200 103 毫秒 - 406 [HTTP] --> POST /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09/location {“location”:{“altitude”:0,“latitude”:20.672267 ,“hCode”:1751403001,“class”:“org.openqa.selenium.html5.Location”,“longitude”:83.1649}} [debug] [MJSONWP] Calling AppiumDriver.setGeoLocation() with args: [{“altitude”:0,“latitude”:20.672267,“hCode”:1751403001,“class”:“org.openqa.selenium.html5.Location”,“longitude”:83.1649},”6909c363-12a5-4a21-9298-c7f750ba7e09“] [debug] [XCUITest] 执行命令 'setGeoLocation' [HTTP] < -- POST /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09/location 501 30 ms - 122 org.openqa.selenium.WebDriverException: 方法尚未实现(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:58 毫秒 构建信息:版本:'3.4.0',修订版:'未知',时间:'未知'系统信息:主机:'Abhays-MacBook-Air.local',ip:'fe80:0:0:0:4fc:aa3c:d673:369e%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_131' 驱动程序信息: io.appium.java_client.ios.IOSDriver Capabilities [{app=src/test/resources/executor/UICatalog.app, networkConnectionEnabled=false, databaseEnabled=false, deviceName=iPhone 6, platform=MAC, maxTypingFrequency=120, newCommandTimeout=0, platformVersion=10.3, webStorageEnabled=false, locationContextEnabled=false, automationName=XCUITest, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, udid=0A41ECE4-6D03-4FEA-A82A-858FDBA6620E}] 会话 ID: 6909c363-12a5-4a21-9298-c7f750ba7e09 atsun.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) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215) atorg.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671) 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 io.appium.java_client.AppiumExecutionMethod.execute(AppiumExecutionMethod.java:46) at org.openqa.selenium.remote.html5.RemoteLocationContext.setLocation(RemoteLocationContext.java:50) at io.appium.java_client.AppiumDriver.setLocation(AppiumDriver.java:400) at org.openqa.selenium.html5.LocationContext$setLocation.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSite.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) at org.codehaus.groovy.runtime.callite.AbstractCallSite.call(AbstractCallSite.java:122) atexecutor.com.bqurious.keyword.mobile.ios.BqIosSetLocationTest.setLocation(BqIosSetLocationTest.groovy:72) at sun.reflect.nativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.nativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statement.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) atorg.junit.internal.runners.statement.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statement.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [HTTP] --> DELETE /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09 {} [debug] [MJSONWP] 用 args 调用 AppiumDriver.deleteSession() : [“6909c363-12a5-4a21-9298-c7f750ba7e09”] [debug] [BaseDriver] 事件 'quitSessionRequested' 记录在 1504013038955 (18:53:58 GMT+0530 (IST)) [调试] [JSONWP 代理] 代理 [DELETE /session/6909c363-12a5-4a21-9298-c7f750ba7e09] 到 [DELETE http://localhost:8100/session/43710C7E-2FDE-4A35-A2E0-4D309EE2CE9C] 没有主体 [debug] [JSONWP Proxy] 得到状态为 200 的响应: “{\n \”value\“ : {\n\n },\n \”sessionId\“ : \”28E97E0B-DF47-4325-8991-A28B77134EDB\“,\n \”status\“ : 0\n}” [XCUITest] 关闭子进程 [XCUITest] 关闭 xcodebuild 进程 (pid 37304) [XCUITest] xcodebuild 退出代码 'null' 和信号 'SIGTERM' [debug] [XCUITest] 找到 WDA 派生的数据文件夹:'/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs' [XCUITest]将 '755' 权限设置为 '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Logs/Test/Attachments' folder [debug] [XCUITest] Found WDA derived data folder: '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-folfazwwukpzfkegdblpnfuwlvfn' [XCUITest] 将 '755' 权限设置为 '/Users/omprakash.mishra/Library/Developer/Xcode/DerivedData/WebDriverAgent-folfazwwukpzfkegdbpfuwlvfn/Logs/测试/附件的文件夹 [调试] [XCUITest] 未清除日志文件。使用功能打开。[调试][iOSLog]停止 iOS 日志捕获 [Appium] 从主会话列表中删除会话 6909c363-12a5-4a21-9298-c7f750ba7e09 [debug] [BaseDriver] 事件“退出会话完成”记录在 1504013039408 (18:53:59 GMT+0530 (IST)) [调试] [MJSONWP] 收到响应: null [debug] [MJSONWP] 但正在删除会话,因此不返回 [debug] [MJSONWP] 使用 driver 响应客户端.deleteSession() 结果: null [HTTP] < -- DELETE /wd/hub/session/6909c363-12a5-4a21-9298-c7f750ba7e09 200 461 毫秒 - 76clearSystemFiles