Unable to launch safari in simulator.
My Source code is below:
package com.mob.safari;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
public class SafariLaunch {
AppiumDriver driver;
@BeforeTest
public void beforeTest() throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability("udid",
// "af5020497b55d10f41a88c488051a85927765a08");
capabilities.setCapability("deviceName", "iPhone 6");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability(CapabilityType.VERSION, "8.4");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Safari");
URL url = new URL("http", "127.0.0.1", 4723, "/wd/hub");
driver = new AppiumDriver<WebElement>(url, capabilities) {
@Override
public MobileElement scrollToExact(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public MobileElement scrollTo(String arg0) {
// TODO Auto-generated method stub
return null;
}
};
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Test
public void Launch() {
driver.get("http://www.google.com");
}
@AfterTest
public void afterTest() {
}
}
Error Logs showing:
info: Welcome to Appium v1.3.1 (REV 1160ce02bb89c354cb99317985123acf39f0e7d3)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“safari”:true,“deviceName”:“iPhone 6”,“browserName”:“Safari”,“showSimulatorLog”:true,“defaultCommandTimeout”:7200}
warn: Deprecated server args: {"–show-sim-log":“use instead: --show-ios-log”}
info: Console LogLevel: debug
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.1”,“revision”:“1160ce02bb89c354cb99317985123acf39f0e7d3”}}}
info: <-- GET /wd/hub/status 200 5.424 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.3.1”,“revision”:“1160ce02bb89c354cb99317985123acf39f0e7d3”}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.1”,“revision”:“1160ce02bb89c354cb99317985123acf39f0e7d3”}}}
info: <-- GET /wd/hub/status 200 1.437 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.3.1”,“revision”:“1160ce02bb89c354cb99317985123acf39f0e7d3”}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.1”,“revision”:“1160ce02bb89c354cb99317985123acf39f0e7d3”}}}
info: <-- GET /wd/hub/status 200 0.857 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.3.1”,“revision”:“1160ce02bb89c354cb99317985123acf39f0e7d3”}}}
info: --> POST /wd/hub/session {“desiredCapabilities”:{“browserName”:“Safari”,“platformName”:“iOS”,“deviceName”:“iPhone 6”,“version”:“8.4”}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_60)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version
info: [debug] Configuring Safari session
info: [debug] Creating new appium session a0846f05-f982-499f-aa99-ba4630a42ec1
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Setting Xcode folder
info: [debug] Setting Xcode version
info: [debug] Setting iOS SDK Version
info: [debug] Getting sdk version from xcrun with a timeout
info: [debug] iOS SDK Version set to 8.4
info: [debug] Checking whether instruments supports our device string
info: [debug] Getting list of devices instruments supports
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: [debug] Getting device string from opts: {“forceIphone”:false,“forceIpad”:false,“xcodeVersion”:“6.4”,“iOSSDKVersion”:“8.4”,“deviceName”:“iPhone 6”,“platformVersion”:null}
info: [debug] fixDevice is on
info: [debug] Final device string is: ‘iPhone 6 (8.4 Simulator)’
info: [debug] iOS sim UDID is F6C90FEA-E092-46EC-9C5D-ABFE4DF3DA84
info: [debug] Trying to use mobile safari, version null
info: [debug] Looking for built in app MobileSafari
warn: App is also not at /tmp/Appium-MobileSafari-null.app
error: Could not prepare mobile safari: Error: Couldn’t find built in app in its home or temp dir!
info: [debug] Cleaning up appium session
info: [debug] Error: Couldn’t find built in app in its home or temp dir!
at /Applications/Appium2.app/Contents/Resources/node_modules/appium/lib/devices/ios/simulator.js:442:21
at Object.oncomplete (fs.js:107:15)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Couldn’t find built in app in its home or temp dir!)”,“origValue”:“Couldn’t find built in app in its home or temp dir!”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 547.809 ms - 224
error: Failed to start an Appium session, err was: Error: Couldn’t find built in app in its home or temp dir!
Please help me resolve this issue
Thanks,
sanoj