Java 如何让SafariLauncher在真正的iPhone上启动Safari

Java 如何让SafariLauncher在真正的iPhone上启动Safari,java,ios,selenium,safari,appium,Java,Ios,Selenium,Safari,Appium,长话短说,我遵循这个教程,现在我有一个项目。不幸的是,我找不到使用网页运行appium的教程。到目前为止,我已经根据自己的需要进行了编辑,也就是说,它带来了google.com,它可以在模拟器中工作 我已经在设备上安装了SafariLauncher。当手动单击应用程序时,它确实起作用 然而,当我使用SafariLauncher和appium时,您可以看出它不起作用 以下是控制台告诉我的-> info: [debug] Attempting to run app on real device wi

长话短说,我遵循这个教程,现在我有一个项目。不幸的是,我找不到使用网页运行appium的教程。到目前为止,我已经根据自己的需要进行了编辑,也就是说,它带来了google.com,它可以在模拟器中工作

我已经在设备上安装了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)

因此,简而言之,有人能让SafariLauncher在真正的设备上工作吗?

如果您想使用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);
如果您只想在真正的手机上使用Safari浏览器,则不需要其他SafariLaucher设置

Saucelabs的SafariTest示例代码仅显示:


您应该使用XCUITest来启动Safari,而不是SafariLauncher

必要的已安装软件

在真实设备上运行iOS测试目前需要两个软件:

libimobiledevice-使用brew安装libimobiledevice -头 ios部署-使用npm安装安装-g ios部署 将真实设备上的WebDriverAgentRunner设置为

在源代码中添加所需的功能配置,如下所示:


那是为了模拟器,不是真正的设备。我想说的是,也许你根本不需要SafariLauncher。这个例子是针对模拟器的,但是你可以对真实的设备做同样的事情。我将更新答案以反映这一点。
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);
platformName: "iOS",
platformVersion: "10.3",
deviceName: "HCiPhone",
browserName: "safari",
udid: "5343fa7f9c04cb60f02cb40f1233073d23dbbbc7",
startIWDP: true,
safariInitialUrl: "https://stackoverflow.com/"