Hello, I am writing test case using java, for ios app. It is taking too much time to launch app in simulator. Also 2-3 times simulator fails/crashes and then app gets installed and then test runs.
Following is the code , please suggest me solution for the same -
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
public class AppiumIOSLogin {
private AppiumDriver driver;
public WebDriver dr;
private List<Integer> values;
private static final int MINIMUM = 0;
private static final int MAXIMUM = 10;
@BeforeMethod
public void setupTest() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "ios");
capabilities.setCapability("platformVersion", "8.1");//7.1
capabilities.setCapability("deviceName", "iPhone Simulator");
String appPath = "/Users/vivekgabje/Documents/workspace/Welcome.zip";
capabilities.setCapability("app", appPath);
try {
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@Test
public void SimpleTest () throws Exception
{
List<WebElement> elems=driver.findElements(By.className("UIATextField"));
for (WebElement elem : elems) {
elem.sendKeys("[email protected]");
}
WebElement txt=driver.findElement(By.className("UIASecureTextField"));
txt.sendKeys("demo123");
WebElement button1 = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]"));
button1.click();
WebElement lbl=driver.findElement(By.className("UIAStaticText"));
WebElement logout = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]"));
logout.click();
}
@AfterMethod
public void tearDown() {
if (driver == null)
driver.quit();
}
}
I am using intelliJ IDEA 14 CE. For Appium set up I have followed following youtube video : https://www.youtube.com/watch?v=HWVvcELQJqI