AppiumNativeAppOnSimulator - gits5213/InterviewProject GitHub Wiki
Problem-1
An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: “Carthage binary is not found. Install using brew install carthage
if it is not installed and make sure the root folder, where carthage binary is installed, is present in PATH environment variable. The current PATH value: ‘/usr/bin:/bin:/usr/sbin:/sbin’“.
Solution-1
1- Right click on your project > Run as > Run Configuration
2- Select Environment
3- Update your project PATH to be like this: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
Create a Project > Package >Test Class
package com.sensitec.stm.testCases;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
public class IOSNativeOnSimulator {
public static IOSDriver wd;
public static AppiumDriverLocalService service;
public static void main(String[] args) throws MalformedURLException {
`//Server Running Programitically `
`service = AppiumDriverLocalService.buildService(`
`new AppiumServiceBuilder().usingDriverExecutable(new File("/usr/local/bin/node"))`
`.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"))`
`.withArgument(GeneralServerFlag.LOCAL_TIMEZONE)`
`.withLogFile(new File(System.getProperty("user.dir")+"/target/Appium.log")));`
`service.start();`
`//File appDir = new File(System.getProperty("user.dir"), "/apps/");`
`//File app = new File(appDir, "UICatalog.app");`
`DesiredCapabilities cap = new DesiredCapabilities();`
`cap.setCapability(MobileCapabilityType.BROWSER_NAME, "");`
`cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "12.1");`
`cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");`
`cap.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8 Simulator");`
`//cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());`
`cap.setCapability("automationName", "XCUITest");`
`//UUID`
`cap.setCapability("udid", "3830BE76-03F4-47A2-9783-5F7EF707118E");`
`//Bundle ID - iPhone8`
`cap.setCapability("app", "com.example.apple-samplecode.UICatalog.app"); `
`//or`
`//cap.setCapability("app", "/Users/zamanmd1/Library/Developer/Xcode/DerivedData/UICatalog-abnhurriijkkosdkcnfdepampyme/Build/Products/Debug-iphonesimulator/UICatalog.app");`
`wd = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);`
`wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);`
wd.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIAStaticText[1]")).click();
wd.quit();
service.stop();
}
}