Use Appium to Enable Automation in AstroFarm for iOS Devices
Prerequisite
- Appium should be installed and configured in the mac system
To enable automation in AstroFarm using Appium, follow these steps:
1. Log into the AstroFarm console.
2. Search for the iOS device that you want to use for automation and click Use.
3. Navigate to the Dashboard and copy the command from Remote Debug.
4. In the Astrofarm contributor agent, click Start Remote Debugging and configure the same with the Remote Debug command.
5. Once done, click Apply & Start.
Below is sample code for execution automation code on Astrofarm iOS device with Appium: import java.net.URL:
import org.openqa.selenium.By;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.google.common.collect.ImmutableMap;
import io.appium.java\_client.ios.IOSDriver;
import io.appium.java\_client.remote.MobileCapabilityType;
public class AstroDeviceExecution {
public static String **deviceUDID**="xxxxxx";
public static String **xcodeOrgId**="xxxxxx";
public static String **platformVersion**="xxxxxx";
public static String **deviceName**="xxxxxxx";
public static void main(String\[\] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "ios");
capabilities.setCapability("platformVersion", platformVersion);
capabilities.setCapability("deviceName", deviceName);
capabilities.setCapability("udid", deviceUDID);
capabilities.setCapability("automationName", "xcuitest");
capabilities.setCapability("xcodeOrgId", xcodeOrgId);
capabilities.setCapability("xcodeSigningId", "Apple Development");
capabilities.setCapability("usePrebuiltWDA", true); capabilities.setCapability("updatedWDABundleId","com.gears42.WebDriverAgent");
capabilities.setCapability("webDriverAgentUrl", "**Automation command**");
capabilities.setCapability("noReset", true);
capabilities.setCapability("skipServerInstallation", true);
capabilities.setCapability("app", "**ApplicationPath**");
IOSDriver driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities); driver.findElement(By.xpath("//XCUIElementTypeButton\[@name='Test'\]")).click(); driver.findElement(By.xpath("//XCUIElementTypeTextField\[@value='Test'\]")).sendKeys("Test");
ImmutableMap pressHome = ImmutableMap.of("name", "home");
driver.executeScript("mobile: pressButton", pressHome);
driver.activateApp("com.apple.Preferences");
driver.quit();
}
}
note
Follow step.6 to obtain the Automation Command.
note
User-defined variables are highlighted in bold.
6. Navigate to the Dashboard > Automation to get the Automation Command.