Hi all, Need help
for the past year I have been writing automated tests for Android,
I install appium + java + node and its work good.
I set up a workspace in intellij with java. I create SetUpDrive Class that create the Devices and before All Test i call the class.
Now i need to start write Automatio test for IOS with MAC.
Im new with mac and i dont know the diffrent between Android and ios about Creting the Devices,
Is it the same ? Is there an example of a working environment for ios with intellij ? (example of Devices create)
This is how i do it in Androin (In intellij) -
public class DriverManager {
private static String appiumJS = System.getenv("APPIUM_HOME")+"/resources/app/node_modules/appium/build/lib/main.js"; //used to create Appium Server;
private static String nodeJS = System.getenv("NODE")+"/node.exe"; //used to create Appium Server
private static String appiumHome = System.getenv("APPIUM_HOME")+"/resources/app/node_modules/appium/build/lib/main.js",
nodeHome = System.getenv("NODE")+"/node.exe";
private static DriverService service;
private static DriverService service1,service2;
private static String deviceID;
private static int port1 = 4723;
private static int port2 = 4727;
private static String host1 = "http://127.0.0.3";
private static String host2 = "http://127.0.0.7";
private static String level = "warn"; //could be 'warn' or 'info' to see or hide appium server logs
private static HashMap<String, URL> hosts;
private static String unlockPackage = "io.appium.unlock";
private static DesiredCapabilities getCaps(String deviceID){
MyLogger.log.info("Creating driver caps for device: " + deviceID);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.DEVICE_NAME, deviceID);
caps.setCapability(MobileCapabilityType.UDID , deviceID);
caps.setCapability(MobileCapabilityType.PLATFORM_NAME , "Android");
caps.setCapability(MobileCapabilityType.APP , "C://Users/gilb/AppData/Local/Programs/appium-desktop/resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/app/src/androidTestE2eTest/java/io/appium/uiautomator2/unittest/resource/ApiDemos-debug.apk");
caps.setCapability("newCommandTimeout", 600);
caps.setCapability("automationName", "uiautomator2");
// caps.setCapability(MobileCapabilityType.APP , "C://Users/gilb/AppData/Local/Programs/appium-desktop/resources/app/node_modules/appium/node_modules/appium-unlock/bin/unlock_apk-debug.apk");
return caps;
}
private static DriverService createService(String host, int port) throws MalformedURLException {
System.out.println("building appium sever on host: "+ host +" with port: "+ port);
DriverService service = new AppiumServiceBuilder()
.usingDriverExecutable(new File(nodeHome))
.withAppiumJS(new File(appiumHome))
.withIPAddress(host.split("//")[1])
.usingPort(port)
.withArgument(Arg.TIMEOUT,"350")
.withArgument(Arg.LOG_LEVEL, level)
.build();
return service;
}
public static void createDriver(int locationInConnectedDevices) throws MalformedURLException {
MyLogger.log.info("method - createDriver");
try {
MyLogger.log.debug("Trying to create new Driver for device: " + SetUpDevices.getConnectedDeviceAtIndex(locationInConnectedDevices).getPhoneModel());
if(locationInConnectedDevices == 0){
service1 = createService(host1,port1);
service1.start();
MyLogger.log.debug("creating driver for: "+host1+":"+port1+"/wd/hub");
Android.driver1 = new AndroidDriver(new URL(host1+":"+port1+"/wd/hub"), getCaps(SetUpDevices.getConnectedDeviceAtIndex(locationInConnectedDevices).getUDID()));
Android.adb1 = new ADB(SetUpDevices.getConnectedDeviceAtIndex(locationInConnectedDevices).getUDID());
} else if (locationInConnectedDevices == 1){
service2 = createService(host2,port2);
service2.start();
MyLogger.log.debug("creating driver for: "+host2+":"+port2+"/wd/hub");
Android.driver2 = new AndroidDriver(new URL(host2+":"+port2+"/wd/hub"), getCaps(SetUpDevices.getConnectedDeviceAtIndex(locationInConnectedDevices).getUDID()));
Android.adb2 = new ADB(SetUpDevices.getConnectedDeviceAtIndex(locationInConnectedDevices).getUDID());
}
}catch(Exception e){
e.printStackTrace();
//Ignore and try next device
}
}
I would highly appreciate any kind of help !!
Thans !