Long story short, I followed this http://appium.io/slate/en/tutorial/ios.html?java# tutorial and now I have a project. Unfortunately, I cannot find a tutorial for running appium with a web page. So far, I have edited to fit my needs, ie let's say it brings up google.com, which works in the emulator.
I have installed SafariLauncher on the device. When manually clicking the app it DOES work.
However, when I use SafariLauncher and appium as you can tell it does not work.
Here is what the console is telling me ->
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)
and here is my relevant code
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);
So in short, can ANYONE get SafariLauncher to work on a real device?
I think you just need to set the browser name capability if you want to run tests with the Safari browser:
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);
and you don't need the other SafariLaucher settings if you just want to use the Safari browser on a real phone.
This SafariTest example code from Saucelabs shows just that:
You should use XCUITest to start Safari instead of SafariLauncher
Necessary installed software
Two pieces of software are currently necessary to run iOS tests on real devices:
libimobiledevice
- install using brew install libimobiledevice --HEAD
ios-deploy
- install using npm install -g ios-deploy
Setting up WebDriverAgentRunner on real device as document
Add desired capabilities config as below in source code:
platformName: "iOS", platformVersion: "10.3", deviceName: "HCiPhone", browserName: "safari", udid: "5343fa7f9c04cb60f02cb40f1233073d23dbbbc7", startIWDP: true, safariInitialUrl: "https://stackoverflow.com/"
You can easily make a web test using Safari browser with free TestProject SDK
Test class:
package io.testproject;
import io.testproject.java.sdk.v2.drivers.IOSDriver;
import io.testproject.java.sdk.v2.enums.ExecutionResult;
import io.testproject.java.sdk.v2.exceptions.FailureException;
import io.testproject.java.sdk.v2.tests.IOSTest;
import io.testproject.java.sdk.v2.tests.helpers.IOSTestHelper;
public class IOSWeb implements IOSTest {
@Override
public ExecutionResult execute(IOSTestHelper helper) throws FailureException {
IOSDriver driver = helper.getDriver();
driver.get("https://google.com");
return null;
}
}
Runner class:
import io.testproject.IOSWeb;
import io.testproject.java.sdk.v2.Runner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
public class IOSRUnner {
Runner runner;
@Before
public void setup() throws InstantiationException{
runner = Runner.createIOSWeb("devToken","udid","name");
}
@After
public void tearDown() throws IOException{
runner.close();
}
@Test
public void runTest() throws Exception{
IOSWeb iosWeb = new IOSWeb();
runner.run(iosWeb);
}
}
It will automatically run your WebTest on Safari on real device connected to your machine
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.