appium在真机上运行IOS实例要注意的几点:包括python和java运行log 和部分关键代码

最近在研究appium对于IOS的自动化测试,发现在真机上运行appium提供的开源的例子遇到了几个block,询问了一个这个方便面的高手并且总结网上搜到的帖子,现在综合一下。

appium 在模拟器中跑,只需要注意app=path

appium真机上运行:1:运行的时候要将APP安装到真机上面

2:运行的时候,不能再开instrument

3:命令行里面启动的时候,参数写错了应该是 appium -U 3d2cad7288a64a5445aa98a2cc220132f2cddd1c --app io.appium  然后代码里面 app=bundleID,而不是那个很长的路径,其中-U 参数后面是真机的uuid,可以打开xcode,在windows下的organise下找到,一般mac连接上ipad后会有绿色圆点

现在贴上真机上运行python实例:

Kingsons-MacBook:Study kingson$ appium -U 1a601f5cd791bc379115095fc81cd69b096582a3 --app com.telenavsoftware.doudouy
info: Welcome to Appium v0.11.4 (REV b04decd191002628c88e9bf475553da1cd04a036)
info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"sessionId":null,"desiredCapabilities":{"device":"iPhone Simulator","platform":"Mac","browserName":"iOS","version":"7.0","app":"com.telenavsoftware.doudouy"}}
info: App is an iOS bundle, will attempt to run as pre-existing
info: Creating new appium session a36fdf63-9b22-48a4-bb01-4b44ddb54aff
info: Removing any remaining instruments sockets
info: Cleaned up instruments socket /tmp/instruments_sock
info: Cleaning up any tracedirs
info: No tracedirs to clean up
info: Localizable.strings is not currently supported when using real devices.
info: Not setting device type since we‘re connected to a device
info: Starting iOS device log capture via idevicesyslog
debug: Real device specified but no ipa, assuming bundle ID is on device
debug: Creating instruments
info: instruments is: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
info: Attempting to run app on real device with UDID 1a601f5cd791bc379115095fc81cd69b096582a3
info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w 1a601f5cd791bc379115095fc81cd69b096582a3 com.telenavsoftware.doudouy -e UIASCRIPT /usr/local/lib/node_modules/appium/lib/devices/ios/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/
info: And extra without-delay env: {}
info: And launch timeout: 90000ms
info: [INST STDERR] 2013-12-10 10:40:22.536 instruments[53424:507] Connection to the remote device lost while launching target. Aborting...

info: [INST STDERR] 2013-12-10 10:40:22.539 instruments[53424:507] Recording cancelled : At least one target failed to launch; aborting run

info: [INST STDERR] Instruments Trace Error : Error Domain=com.apple.instruments Code=1 "Error Starting Recording" UserInfo=0x7ff6d308f220 {NSLocalizedDescription=Error Starting Recording, NSLocalizedRecoverySuggestion=At least one target failed to launch; aborting run}
Instruments Trace Error : Failed to start trace.

info: [INSTSERVER] Instruments exited with code 253
error: Instruments did not launch successfully, failing session
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Instruments did not launch successfully--please check your app paths or bundle IDs and try again
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments did not launch successfully--please check your app paths or bundle IDs and try again)","origValue":"Instruments did not launch successfully--please check your app paths or bundle IDs and try again"},"sessionId":null}
POST /wd/hub/session 500 6015ms - 342b```

我的部分代码片段:

```python
class TestSequenceFunctions(unittest.TestCase):

    def setUp(self):
        # set up appium
        app = "com.telenavsoftware.doudouy"
        #app = os.path.join(os.path.dirname(__file__),
        #                   ‘../../apps/DDY/build/‘,
        #                   ‘DouDouY.app‘)
        #app = os.path.abspath(app)
        self.driver = webdriver.Remote(
            command_executor=‘http://127.0.0.1:4723/wd/hub‘,
            desired_capabilities={
                ‘browserName‘: ‘iOS‘,
                ‘device‘: ‘iPhone Simulator‘,
                ‘platform‘: ‘Mac‘,
                ‘version‘: ‘7.0‘,
                ‘app‘: app
            })```

1.启动Appium时,保证你的Real
Device的UDID和你的应用的Bundle ID正确

2.确保你的应用可以安装到你的真机上

3.安装后请断开与Xcode的连接

4.确保Mac上没有启动Instruments工具

以下是JAVA运行log:

devexus-iMac:build devexu$
appium -U 3d2cad7288a64a5445aa98a2cc220132f2cddd1c --app io.appium

info: Welcome to Appium v1.1.0 (REV e433bbc31511f199287db7724e1ce692bcb32117)

info: Appium REST http interface listener started on 0.0.0.0:4723

info: socket.io started

info: Non-default server args: {"app":"io.appium","udid":"3d2cad7288a64a5445aa98a2cc220132f2cddd1c"}

debug: Appium request initiated at /wd/hub/session

debug: Request received with params: {"desiredCapabilities":{"platformVersion":"7.1","app":"io.appium.TestApp","platformName":"iOS","deviceName":"iPhone Simulator","browserName":""}}

info: App is an iOS bundle, will attempt to run as pre-existing

info: Creating new appium session 2bcd619b-b7fb-45f5-b20c-79caff8cd24f

info: Removing any remaining instruments sockets

info: Cleaned up instruments socket /tmp/instruments_sock

info: Cleaning up any tracedirs

info: No tracedirs to clean up

info: Setting Xcode folder

info: Setting Xcode version

info: Setting iOS SDK Version

info: iOS SDK Version set to 7.1

info: Detecting automation tracetemplate

info: Not auto-detecting udid, running on sim

info: Localizable.strings is not currently supported when using real devices.

info: Not setting locale because we‘re using a real device

debug: Creating instruments

info: Not setting iOS and app preferences since we‘re on a real device

info: Starting iOS device log capture via idevicesyslog

info: Not setting device type since we‘re connected to a device

debug: Real device specified but no ipa or app path, assuming bundle ID is on device

debug: Starting instruments

info: Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock

info: Attempting to run app on real device with UDID 3d2cad7288a64a5445aa98a2cc220132f2cddd1c

info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
-w 3d2cad7288a64a5445aa98a2cc220132f2cddd1c io.appium.TestApp -e UIASCRIPT /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments

info: And extra without-delay env: {}

info: And launch timeouts (in ms): {"global":90000}

info: [INST] 2014-07-02 01:29:30 +0000 Start: Bootstrapping uiauto

info: [INST] 2014-07-02 01:29:32 +0000 Start: Got user: devexu

info: [INST] 2014-07-02 01:29:33 +0000 Start: Not using settings file.

info: [INST] 2014-07-02 01:29:33 +0000 Start: isVerbose:false

info: [INST] 2014-07-02 01:29:37 +0000 Start: Using node at: /usr/local/bin/node

info: [INSTSERVER] Instruments is ready to receive commands

info: Instruments launched. Starting poll loop for new commands.

info: Setting bootstrap config keys/values

info: Pushing command to appium work queue: "setBootstrapConfig: autoAcceptAlerts=false"

debug: Sending command to instruments: setBootstrapConfig: autoAcceptAlerts=false

info: [INSTSERVER] Socket data received (15 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Sending command to instruments: setBootstrapConfig: autoAcceptAlerts=false

info: [INSTSERVER] Socket data received (48 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":""}

info: Setting initial orientation to PORTRAIT

info: Pushing command to appium work queue: "au.setScreenOrientation(‘PORTRAIT‘)"

debug: Sending command to instruments: au.setScreenOrientation(‘PORTRAIT‘)

info: [INSTSERVER] Sending command to instruments: au.setScreenOrientation(‘PORTRAIT‘)

info: [INST] 2014-07-02 01:29:41 +0000 Debug: target.setDeviceOrientation("1")

info: [INSTSERVER] Socket data received (56 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":"PORTRAIT"}

info: Device launched! Ready for commands

info: Setting command timeout to the default of 60 secs

info: Appium session started with sessionId 2bcd619b-b7fb-45f5-b20c-79caff8cd24f

POST /wd/hub/session 303 22483ms - 9b

debug: Appium request initiated at /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f

debug: Request received with params: {}

info: Responding to client with success: {"status":0,"value":{"webStorageEnabled":false,"locationContextEnabled":false,"browserName":"","platform":"MAC","javascriptEnabled":true,"databaseEnabled":false,"takesScreenshot":true,"warnings":{},"desired":{"platformVersion":"7.1","app":"io.appium.TestApp","platformName":"iOS","deviceName":"iPhone
Simulator","browserName":""},"platformVersion":"7.1","app":"io.appium.TestApp","platformName":"iOS","deviceName":"iPhone Simulator"},"sessionId":"2bcd619b-b7fb-45f5-b20c-79caff8cd24f"}

GET /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f
200 3ms - 624b

debug: Appium request initiated at /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element

debug: Request received with params: {"using":"xpath","value":"//UIATextField[1]"}

info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"

debug: Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Socket data received (6682 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"TestApp\",\"label\":\"TestApp\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":64,\"y\":72,\"width\":640,\"height\":920},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\"

info: Pushing command to appium work queue: "au.getElementByIndexPath(‘/0/1/0‘)"

debug: Sending command to instruments: au.getElementByIndexPath(‘/0/1/0‘)

info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath(‘/0/1/0‘)

info: [INSTSERVER] Socket data received (61 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"0"}}

info: Responding to client with success: {"status":0,"value":{"ELEMENT":"0"},"sessionId":"2bcd619b-b7fb-45f5-b20c-79caff8cd24f"}

POST /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element
200 2258ms - 109b

debug: Appium request initiated at /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element/0/displayed

debug: Request received with params: {}

info: Pushing command to appium work queue: "au.getElement(‘0‘).isDisplayed()"

debug: Sending command to instruments: au.getElement(‘0‘).isDisplayed()

info: [INSTSERVER] Sending command to instruments: au.getElement(‘0‘).isDisplayed()

info: [INSTSERVER] Socket data received (50 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":true}

info: Responding to client with success: {"status":0,"value":true,"sessionId":"2bcd619b-b7fb-45f5-b20c-79caff8cd24f"}

GET /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element/0/displayed200
997ms - 89b

debug: Appium request initiated at /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element

debug: Request received with params: {"using":"xpath","value":"//UIAButton[1]"}

info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"

debug: Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Socket data received (6682 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"TestApp\",\"label\":\"TestApp\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":64,\"y\":72,\"width\":640,\"height\":920},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\"

info: Pushing command to appium work queue: "au.getElementByIndexPath(‘/0/1/2‘)"

debug: Sending command to instruments: au.getElementByIndexPath(‘/0/1/2‘)

info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath(‘/0/1/2‘)

info: [INSTSERVER] Socket data received (61 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"1"}}

info: Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"2bcd619b-b7fb-45f5-b20c-79caff8cd24f"}

POST /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element
200 2255ms - 109b

debug: Appium request initiated at /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element/1/displayed

debug: Request received with params: {}

info: Pushing command to appium work queue: "au.getElement(‘1‘).isDisplayed()"

debug: Sending command to instruments: au.getElement(‘1‘).isDisplayed()

info: [INSTSERVER] Sending command to instruments: au.getElement(‘1‘).isDisplayed()

info: [INSTSERVER] Socket data received (50 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":true}

info: Responding to client with success: {"status":0,"value":true,"sessionId":"2bcd619b-b7fb-45f5-b20c-79caff8cd24f"}

GET /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f/element/1/displayed200
1059ms - 89b

debug: Appium request initiated at /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f

debug: Request received with params: {}

info: Shutting down appium session...

info: Stopping ios

info: Sending sigterm to instruments

info: [INST] 2014-07-02 01:29:47 +0000 Stopped: Script was stopped by the user

info: [INST] Instruments Trace Complete (Duration : 23.735861s; Output : /usr/local/lib/node_modules/appium/instrumentscli0.trace)

info: [INSTSERVER] Instruments exited with code 0

info: Cleaning up after instruments exit

info: [INSTSERVER] Closing instruments client socket due to exit

info: Stopping iOS log capture

info: Killing the simulator process

info: [INSTSERVER] Instruments socket server was closed

info: Killing any other simulator daemons

info: Cleaning app state.

info: No folders found to remove

info: Cleaning up appium session

info: Responding to client with success: {"status":0,"value":null,"sessionId":"2bcd619b-b7fb-45f5-b20c-79caff8cd24f"}

DELETE /wd/hub/session/2bcd619b-b7fb-45f5-b20c-79caff8cd24f
200 1156ms - 89b

debug: Appium request initiated at /wd/hub/session

debug: Request received with params: {"desiredCapabilities":{"platformVersion":"7.1","app":"io.appium.TestApp","platformName":"iOS","deviceName":"iPhone Simulator","browserName":""}}

info: App is an iOS bundle, will attempt to run as pre-existing

info: Creating new appium session d04b8af0-bf77-4c73-957a-9321af31b2df

info: Removing any remaining instruments sockets

info: Cleaned up instruments socket /tmp/instruments_sock

info: Cleaning up any tracedirs

info: Cleaned up /usr/local/lib/node_modules/appium/instrumentscli0.trace

info: Setting Xcode folder

info: Setting Xcode version

info: Setting iOS SDK Version

info: iOS SDK Version set to 7.1

info: Detecting automation tracetemplate

info: Not auto-detecting udid, running on sim

info: Localizable.strings is not currently supported when using real devices.

info: Not setting locale because we‘re using a real device

debug: Creating instruments

info: Not setting iOS and app preferences since we‘re on a real device

info: Starting iOS device log capture via idevicesyslog

info: Not setting device type since we‘re connected to a device

debug: Real device specified but no ipa or app path, assuming bundle ID is on device

debug: Starting instruments

info: Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock

info: Attempting to run app on real device with UDID 3d2cad7288a64a5445aa98a2cc220132f2cddd1c

info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
-w 3d2cad7288a64a5445aa98a2cc220132f2cddd1c io.appium.TestApp -e UIASCRIPT /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments

info: And extra without-delay env: {}

info: And launch timeouts (in ms): {"global":90000}

info: [INST] 2014-07-02 01:40:56 +0000 Start: Bootstrapping uiauto

info: [INST] 2014-07-02 01:40:58 +0000 Start: Got user: devexu

info: [INST] 2014-07-02 01:40:59 +0000 Start: Not using settings file.

info: [INST] 2014-07-02 01:40:59 +0000 Start: isVerbose:false

info: [INST] 2014-07-02 01:41:03 +0000 Start: Using node at: /usr/local/bin/node

info: [INSTSERVER] Instruments is ready to receive commands

info: Instruments launched. Starting poll loop for new commands.

info: Setting bootstrap config keys/values

info: Pushing command to appium work queue: "setBootstrapConfig: autoAcceptAlerts=false"

debug: Sending command to instruments: setBootstrapConfig: autoAcceptAlerts=false

info: [INSTSERVER] Socket data received (15 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Sending command to instruments: setBootstrapConfig: autoAcceptAlerts=false

info: [INSTSERVER] Socket data received (48 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":""}

info: Setting initial orientation to PORTRAIT

info: Pushing command to appium work queue: "au.setScreenOrientation(‘PORTRAIT‘)"

debug: Sending command to instruments: au.setScreenOrientation(‘PORTRAIT‘)

info: [INSTSERVER] Sending command to instruments: au.setScreenOrientation(‘PORTRAIT‘)

info: [INST] 2014-07-02 01:41:08 +0000 Debug: target.setDeviceOrientation("1")

info: [INSTSERVER] Socket data received (56 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":"PORTRAIT"}

info: Device launched! Ready for commands

info: Setting command timeout to the default of 60 secs

info: Appium session started with sessionId d04b8af0-bf77-4c73-957a-9321af31b2df

POST /wd/hub/session 303 18457ms - 9b

debug: Appium request initiated at /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df

debug: Request received with params: {}

info: Responding to client with success: {"status":0,"value":{"webStorageEnabled":false,"locationContextEnabled":false,"browserName":"","platform":"MAC","javascriptEnabled":true,"databaseEnabled":false,"takesScreenshot":true,"warnings":{},"desired":{"platformVersion":"7.1","app":"io.appium.TestApp","platformName":"iOS","deviceName":"iPhone
Simulator","browserName":""},"platformVersion":"7.1","app":"io.appium.TestApp","platformName":"iOS","deviceName":"iPhone Simulator"},"sessionId":"d04b8af0-bf77-4c73-957a-9321af31b2df"}

GET /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df
200 1ms - 624b

debug: Appium request initiated at /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element

debug: Request received with params: {"using":"xpath","value":"//UIATextField[1]"}

info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"

debug: Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Socket data received (6682 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"TestApp\",\"label\":\"TestApp\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":64,\"y\":72,\"width\":640,\"height\":920},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\"

info: Pushing command to appium work queue: "au.getElementByIndexPath(‘/0/1/0‘)"

debug: Sending command to instruments: au.getElementByIndexPath(‘/0/1/0‘)

info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath(‘/0/1/0‘)

info: [INSTSERVER] Socket data received (61 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"0"}}

info: Responding to client with success: {"status":0,"value":{"ELEMENT":"0"},"sessionId":"d04b8af0-bf77-4c73-957a-9321af31b2df"}

POST /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element
200 2337ms - 109b

debug: Appium request initiated at /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element/0/displayed

debug: Request received with params: {}

info: Pushing command to appium work queue: "au.getElement(‘0‘).isDisplayed()"

debug: Sending command to instruments: au.getElement(‘0‘).isDisplayed()

info: [INSTSERVER] Sending command to instruments: au.getElement(‘0‘).isDisplayed()

info: [INSTSERVER] Socket data received (50 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":true}

info: Responding to client with success: {"status":0,"value":true,"sessionId":"d04b8af0-bf77-4c73-957a-9321af31b2df"}

GET /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element/0/displayed200
1056ms - 89b

debug: Appium request initiated at /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element

debug: Request received with params: {"using":"xpath","value":"//UIAButton[1]"}

info: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"

debug: Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Sending command to instruments: au.mainApp().getTreeForXML()

info: [INSTSERVER] Socket data received (6682 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":"{\"UIAApplication\":{\"@\":{\"name\":\"TestApp\",\"label\":\"TestApp\",\"value\":null,\"dom\":null,\"enabled\":true,\"valid\":true,\"visible\":true,\"hint\":null,\"path\":\"/0\",\"x\":64,\"y\":72,\"width\":640,\"height\":920},\">\":[{\"UIAWindow\":{\"@\":{\"name\":null,\"label\"

info: Pushing command to appium work queue: "au.getElementByIndexPath(‘/0/1/2‘)"

debug: Sending command to instruments: au.getElementByIndexPath(‘/0/1/2‘)

info: [INSTSERVER] Sending command to instruments: au.getElementByIndexPath(‘/0/1/2‘)

info: [INSTSERVER] Socket data received (61 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"1"}}

info: Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"d04b8af0-bf77-4c73-957a-9321af31b2df"}

POST /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element
200 2253ms - 109b

debug: Appium request initiated at /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element/1/displayed

debug: Request received with params: {}

info: Pushing command to appium work queue: "au.getElement(‘1‘).isDisplayed()"

debug: Sending command to instruments: au.getElement(‘1‘).isDisplayed()

info: [INSTSERVER] Sending command to instruments: au.getElement(‘1‘).isDisplayed()

info: [INSTSERVER] Socket data received (50 bytes)

info: [INSTSERVER] Socket data being routed for ‘cmd‘ event

info: [INSTSERVER] Got result from instruments: {"status":0,"value":true}

info: Responding to client with success: {"status":0,"value":true,"sessionId":"d04b8af0-bf77-4c73-957a-9321af31b2df"}

GET /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df/element/1/displayed200
1058ms - 89b

debug: Appium request initiated at /wd/hub/session/d04b8af0-bf77-4c73-957a-9321af31b2df

debug: Request received with params: {}

info: Shutting down appium session...

info: Stopping ios

info: Sending sigterm to instruments

info: [INST] 2014-07-02 01:41:13 +0000 Stopped: Script was stopped by the user

info: [INST] Instruments Trace Complete (Duration : 21.512508s; Output : /usr/local/lib/node_modules/appium/instrumentscli0.trace)

info: [INSTSERVER] Instruments exited with code 0

info: Cleaning up after instruments exit

info: [INSTSERVER] Closing instruments client socket due to exit

info: Stopping iOS log capture

info: Killing the simulator process

info: [INSTSERVER] Instruments socket server was closed

info: Killing any other simulator daemons

info: Cleaning app state.

info: No folders found to remove

info: Cleaning up appium session

info: Responding to client with success: {"status":0,"value":null,"sessionId":"d04b8af0-bf77-4c73-957a-9321af31b2df"}

java运行的代码:

package com.saucelabs.appium;

import static org.junit.Assert.assertTrue;

import io.appium.java_client.AppiumDriver;

import io.appium.java_client.MobileBy;

import java.net.URL;

import java.util.ArrayList;

import java.util.List;

import java.util.Random;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import org.openqa.selenium.By;

import org.openqa.selenium.Dimension;

import org.openqa.selenium.Point;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.remote.CapabilityType;

import org.openqa.selenium.remote.DesiredCapabilities;

/**

* Simple <a href="https://github.com/appium/appium">Appium</a> test which runs

* against a local Appium instance deployed with the ‘TestApp‘ iPhone project

* which is included in the Appium source distribution.

*

* @author Ross Rowe

*/

public class WiMyOffice {

private AppiumDriver     driver;

private List<Integer>    values;

private static final int MINIMUM = 0;

private static final int MAXIMUM = 10;

private Point getCenter(final WebElement element) {

final Point upperLeft = element.getLocation();

final Dimension dimensions = element.getSize();

return new Point(upperLeft.getX() + dimensions.getWidth() / 2,

upperLeft.getY() + dimensions.getHeight() / 2);

}

private void populate() {

// populate text fields with two random number

final List<WebElement> elems = driver.findElements(By

.className("UIATextField"));

final Random random = new Random();

for (final WebElement elem : elems) {

final int rndNum = random.nextInt(MAXIMUM - MINIMUM + 1) + MINIMUM;

elem.sendKeys(String.valueOf(rndNum));

values.add(rndNum);

}

}

@Before

public void setUp() throws Exception {

// set up appium

final DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(CapabilityType.BROWSER_NAME, "");

capabilities.setCapability("platformVersion", "7.1");

capabilities.setCapability("platformName", "iOS");

capabilities.setCapability("deviceName", "iPhone Simulator");

capabilities.setCapability("app", "io.appium.TestApp");

driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),

capabilities);

values = new ArrayList<Integer>();

}

@After

public void tearDown() throws Exception {

driver.quit();

}

@Test

public void testHideKeyboard() throws Exception {

driver.findElement(By.xpath("//UIATextField[1]")).sendKeys("12");

final WebElement button = driver.findElement(MobileBy

.AccessibilityId("Done"));

assertTrue(button.isDisplayed());

button.click();

}

}

appium在真机上运行IOS实例要注意的几点:包括python和java运行log 和部分关键代码

时间: 2024-08-08 01:16:01

appium在真机上运行IOS实例要注意的几点:包括python和java运行log 和部分关键代码的相关文章

Charles学习(四)之使用Map local代理本地静态资源以及配置移动端代理在真机上调试iOS和Android客户端

前言 问题一:我们在App内嵌H5开发的过程中,肯定会遇到一个问题就是我不想在chrome的控制台中调试也不想在模拟器中调试,我想要在真机上调试,那么如何解决这个问题呢? 问题二:我们期待调试时达到的效果就是和Charles学习(二)之使用Map local代理本地静态资源在Mac上调试移动端中实现的效果相同,也就是说代码更改手机端页面实时更新,这个问题如何解决? 方案 问题一解决方案:使用真机,需要一台iPhone和一台Android,在真机上安装测试包 问题二解决方案: 配置移动端代理 | 

实验 1 Java 运行环境的安装、配置与运行

一.实验目的     1. 掌握下载 Java SDK 软件包.     2. 掌握设置 Java 程序运行环境的方法.     3. 掌握编写与运行 Java 程序的方法.     4. 了解 Java 语言的概貌. 5. 安装.掌握JCreator软件,为学习 Java 语言和进行 Java 程序的实验做好准备工作. 6. 浏览Applet 程序 二.实验要求     1. 安装并设置 Java SDK 软件包.     2. 编写一个简单的 Java 程序,在屏幕上输出"hello,jav

appium在android 7.0真机上运行报错command failed shell:............ps:&#39;uiautomator&quot;的解决方式

appium版本:1_4_16 在CSDN中找到相关解决的方案,根据此解决方案顺利的解决了让人惆怅的问题,再次记录. 1.找到appium安装目录下的adb.js文件,目录为:Appium\node_modules\appium\node_modules\appium-adb\lib 2.打开adb.js,可使用notepad++编辑器等打开文件(说明:在修改代码的时候先注释掉以前的代码,并且添加自己容易识别的标记,以防出错后还有回旋的余地,或者将代码备份也可行),找到如下代码: ADB.pro

如何将自己编写的软件放在真机上运行

想要将自己编写的软件放到真正的iPhone上去运行,首先你需要成为Apple Developer计划的成员.其次,你需要设置程序ID和认证书,在这之后你就可以在你指定的iPhone上运行你的程序了.下面我将会告诉你如何设置你的程序ID和认证书,让你的程序在iPhone上跑起来. 首先你需要登陆你的Developer Member Center(Developer.apple.com),然后进入iOS Dev Center(iOS开发者中心).在页面的右侧找到iOS Provisioning Po

在ios7真机上和iOS6模拟器上运行是好的,而在iOS6真机上运行却报错

在ios7真机上和iOS6模拟器上运行是好的,而在iOS6真机上运行却报错 解决方法: 或是都设置为yes.. Build Active Architecture Only的意思是只生成适应的指令集 在ios7真机上和iOS6模拟器上运行是好的,而在iOS6真机上运行却报错,码迷,mamicode.com

让Qt for Windows Phone 8.1在真机上运行

前面几篇博文是为这篇文章做铺垫的,最终目的为的是使用Qt框架制作出能够在Windows Phone 8.1真机上运行的程序.由于Qt for WP8这一块不完善,在加上我刚进入这一领域,所以研究的速度有点儿慢.在网上询问了Qt项目的维护者,加上自己的一点研究,稍微了解了Qt for Windows Phone 8的开发原理. 原创文章,反对未声明的引用.原博客地址:http://blog.csdn.net/gamesdev/article/details/38967749 使用Qt开发Windo

关于多行文本 textarea 在ios 真机上padding相对安卓较大问题

问题: 多行文本组件是带有默认的padding的,然而,小程序的teatarea 在ios和安卓上显示的padding不一样,普遍ios的padding会比安卓的要明显的大.这种情况下我的想法是做兼容,也就是分别处理. 在小程序官方文档中是有方法得知当前使用小程序的机型的,即 wx.getSystemInfoSync()  ,官方文档链接是:https://mp.weixin.qq.com/debug/wxadoc/dev/api/systeminfo.html#wxgetsysteminfos

iOS 真机上图标不显示

今天在调试时发现模拟器上图标显示了.但真机上测试时发现图标不显示. 解决办法 57*57  的图标然后命名为: Icon.png 这样显示就正常了. 参考资料:http://www.cnblogs.com/niit-soft-518/p/4078476.html

Xcode7真机调试iOS应用程序

金田 近日苹果发布的新的Xcode7带来了许多特性,比如:swift语言比以前运行更快.功能更强.代码具有更高的可读性.Xcode的测试功能可以帮助用户记录应用程序的行为等,还有我们今天要讲到的Xcode7可以免费真机测试iOS应用程序了. 以前的Xcode版本如果需要真机测试都需要付费99美刀购买开发者账号,这增加了新手开发的经济成本,现在苹果将这项功能免费提供,无疑能吸引更多的人涌入iOS开发平台,另外苹果将原来三种平台开发者账号合而为一了,一个账号就可以搞定所有平台,这也节省了软件公司的成