1

应用程序:1.4.13

代码:7.1

IOS:9.1

desired_caps = dict()
            desired_caps['platformName'] = 'iOS'
            desired_caps['platformVersion'] = '9.1'
            desired_caps['deviceName'] = 'iPhone 6'
            desired_caps['app'] = os.path.abspath('/Users/Test.app')
            self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

即使连接了真实设备,它也总是启动模拟器。

我正在尝试在设备上运行。

模拟器不断启动和关闭。

info: [debug] Starting command proxy.
info: [debug] Instruments socket server started at /tmp/instruments_sock
info: [debug] Starting instruments
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (9.1) [
info: On xcode 7.0, instruments-without-delay does not work, skippinginstruments-without-delay
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 "iPhone 6 (9.1) [" /Users/Test.app -e UIASCRIPT "/Users/Library/Application Support/appium/bootstrap/bootstrap-bf740a9394e481ef.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] 2015-10-21 13:29:31.895 instruments[3192:50268] WebKit Threading Violation - initial use of WebKit from a secondary thread.
info: [debug] [INST STDERR] 2015-10-21 13:29:53.976 instruments[3192:50261] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] 2015-10-21 13:29:53.976 instruments[3192:51306] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.) : Failed to launch process with bundle identifier 'com.apsalar.sdkBatchTest2'
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall Simulator
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (9.1) [
info: On xcode 7.0, instruments-without-delay does not work, skippinginstruments-without-delay
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 "iPhone 6 (9.1) [" /Users/Test.app -e UIASCRIPT "/Users/Library/Application Support/appium/bootstrap/bootstrap-bf740a9394e481ef.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST STDERR] 2015-10-21 13:30:00.033 instruments[3298:51578] **WebKit Threading Violation - initial use of WebKit from a secondary thread.**
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] 2015-10-21 13:30:07.851 instruments[3298:51576] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] 2015-10-21 13:30:07.851 instruments[3298:51577] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.) : Failed to launch process with bundle identifier 'com.apsalar.sdkBatchTest2'
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
4

3 回答 3

0

添加 udid 有效!

desired_caps = dict()
            desired_caps['platformName'] = 'iOS'
            desired_caps['platformVersion'] = '9.1'
            desired_caps['deviceName'] = 'iPhone 6'
            desired_caps['udid'] = '09d905a109245efebd23ab741c0900e83769b3ae'
            desired_caps['app'] = os.path.abspath('/Users/Test.app')
            self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
于 2015-10-21T21:36:34.357 回答
0

添加“udid”功能并在此处输入您的设备 udid。

capabilities.setCapability("deviceName", "phoneUDID");
于 2015-10-21T21:37:20.970 回答
0

1)首先:启用iOS设备设置>开发人员>启用UI自动化的UIAutomation

2)用真机UDID启动Appium实例

喜欢:节点。-p 4725 -bp 2553 -U“”

3)并在您的测试代码中添加功能,如下所示:

    File rootDir = new File(System.getProperty("user.dir"));
    File appDir = new File(rootDir, "folder");
    File app = new File(appDir, AppName);

    DesiredCapabilities capabilities = new DesiredCapabilities();

    /*Capabilities for Simulator*/
//  capabilities.setCapability("deviceName", "iPhone 6");
    /*Capabilities for Simulator*/

    /*Capabilities for Device*/
    capabilities.setCapability("deviceName", "Wasim~iPhone");
    /*Capabilities for Device*/

    capabilities.setCapability("platformVersion", "9.1");
    capabilities.setCapability("platformName", "iOS");
    capabilities.setCapability("autoAcceptAlerts",true); //this auto accepts the Notification alert

    capabilities.setCapability("platformVersion", "9.1");
    capabilities.setCapability("noReset",true);

    if (isfirstTimeStart) {

        capabilities.setCapability("app", app.getAbsolutePath());

    }else {

        capabilities.setCapability("bundleId", bundleId);

    }

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

所以 DeviceName 在 Device 上运行很重要,在运行 appium 服务器实例时 UDID 也很重要。

于 2015-11-12T13:45:51.157 回答