Appium如何在物理设备上运行

时间:2015-07-21 14:48:55

标签: java ios appium

所以我试图在一个真实的物理设备上运行我的测试,但它总是一直说该仪器在启动时崩溃。这是错误代码

info: [debug] Attempting to run app on real device with UDID 70cb6f4fd5e313b16742c083ccbc1897d82b094d
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w 70cb6f4fd5e313b16742c083ccbc1897d82b094d com.weather.corp.TWC -e UIASCRIPT "/Users/michael.kovalsky/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INSTSERVER] Instruments exited with code 253

info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons

error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

info: [debug] On a real device; cannot clean device state
info: [debug] Cleaning up appium session
info: [debug] Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:389:31)
    at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308:12)
    at ChildProcess.emit (events.js:110:17)
    at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
info: <-- POST /wd/hub/session 500 19219.862 ms - 182 

And this is how my setUp method looks like:

    public void setUp() throws FileNotFoundException, IOException, IllegalMonitorStateException
    {

        //Users/user/Library/Developer/Xcode/DerivedData/iPhone-aowtfpozolcnpigbxzxxxxkyiubq/Build/Products/Debug-iphonesimulator/TheWeather.app
        File app = new File("/Users/michael.kovalsky/Library/Developer/Xcode/DerivedData/iPhone-aowtfpozolcnpigbxzxxxxkyiubq/Build/Products/Debug-iphonesimulator/TheWeather.app");


        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "iOS");

        capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "8.3");

        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6 Plus");

        capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
        capabilities.setCapability("bundleID", "com.weather.corp.TWC");
        capabilities.setCapability("udid", "70cb6f4fd5e313b16742c083ccbc1897d82b094d");


        driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);

        logger.info("Environment: iOS 8.3 and iPhone 6 plus Simulator");

    }

如果我注释掉我的“udid”,那么模拟器会正常启动,因此它根本不会启动。但是,我需要它启动到我的设备连接到机器。我错过了一些简单的东西吗?

1 个答案:

答案 0 :(得分:1)

您可能缺少ios webkit代理。 请参阅此Link,其中包括从安装到运行的完整文档。

在运行测试启动代理之前。