2014-11-21 41 views
0

長話短說,我遵循這個http://appium.io/slate/en/tutorial/ios.html?java#教程,現在我有一個項目。不幸的是,我找不到用網頁運行appium的教程。到目前爲止,我已經編輯以適應我的需求,即讓我們說它帶來了google.com,它可以在模擬器中工作。如何讓SafariLauncher在真正的iPhone上啓動Safari

我已經在設備上安裝了SafariLauncher。當手動點擊應用程序它工作。

但是,當我使用SafariLauncher和appium時,您可以告訴它不起作用。

這裏是控制檯告訴我 - >

info: [debug] Attempting to run app on real device with UDID 5343fa7f9c04cb60f02cb40f1233073d23dbbbc7 
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.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w 5343fa7f9c04cb60f02cb40f1233073d23dbbbc7 /Users/wroberts/Library/Developer/Xcode/DerivedData/SafariLauncher-fvxpuhbhozeuydcsrdzjhhzlzpsu/Build/Products/Debug-iphoneos/SafariLauncher.app -e UIASCRIPT "/Users/wroberts/Library/Application Support/appium/bootstrap/bootstrap-971fed56c9389ee5.js" -e UIARESULTSPATH /tmp/appium-instruments 
info: [debug] And extra without-delay env: {} 
info: [debug] And launch timeouts (in ms): {"global":90000} 
info: [debug] [INST STDERR] 2014-11-21 15:09:18.206 instruments[19158:3c0b] Error fetching kdebug events 
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 iPhoneSimulator 
info: [debug] Killing any other simulator daemons 
info: [debug] On a real device; cannot clean device state 
info: [debug] Cleaning up appium session 
error: Failed to start an Appium session, err was: Error: Instruments crashed on startup 
info: [debug] Error: Instruments crashed on startup 
    at Instruments.onInstrumentsExit (/Users/wroberts/dev/differnt_svns/mobile_automation/appium/submodules/appium-instruments/lib/instruments.js:387:31) 
    at null.<anonymous> (/Users/wroberts/dev/differnt_svns/mobile_au`enter code here`tomation/appium/submodules/appium- instruments/lib/instruments.js:308:12) 
    at ChildProcess.emit (events.js:98:17) 
    at Process.ChildProcess._handle.onexit (child_process.js:809:12) 

,這裏是我的相關代碼

DesiredCapabilities capabilities = new DesiredCapabilities(); 

    capabilities.setCapability("appium-version", "1.3.1"); 

    //capabilities.setCapability("platformVersion", "8.1"); 

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

    capabilities.setCapability("deviceName", "Tahir's iPhone"); 

    capabilities.setCapability("udid", "5343fa7f9c04cb60f02cb40f1233073d23dbbbc7"); 

    String bundle = "/Users/wroberts/Library/Developer/Xcode/DerivedData/SafariLauncher-fvxpuhbhozeuydcsrdzjhhzlzpsu/Build/Products/Debug-iphoneos/SafariLauncher.app"; 

    capabilities.setCapability("bundleId", bundle); 


    capabilities.setCapability("app", bundle); 


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

    driver.get("http://www.google.com"); 
    Thread.sleep(20000); 

因此,在短期,任何人都可以得到SafariLauncher一個真實的設備嗎?

回答

0

我想你只需要設置瀏覽器的名稱能力,如果你想運行與Safari瀏覽器測試:

DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setCapability("appium-version", "1.3.1"); 
capabilities.setCapability("platformName", "iOS"); 
capabilities.setCapability("deviceName", "Tahir's iPhone"); 
capabilities.setCapability("udid", "your_udid"); 
capabilities.setCapability("bundleId", bundle); 
capabilities.setCapability("browserName", "safari"); 
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);  

driver.get("http://www.google.com"); 
Thread.sleep(20000); 

,如果你只是想用你不需要其他SafariLaucher設置真正的手機上的Safari瀏覽器。

從Saucelabs此SafariTest示例代碼顯示這一點:

https://github.com/appium/sample-code/blob/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/SafariTest.java

+0

即用於模擬器,而不是真實設備。 – user2879041 2014-11-24 15:41:12

+0

我想說的是,也許你根本不需要SafariLauncher。這個例子是針對模擬器的,但您可以對真實設備進行相同的操作。我會更新答案以反映這一點。 – 2014-12-16 13:45:26

相關問題