private IOSDriver<WebElement> driver;
private ScreenRecorder screenRecorder;
@Test
public void f() {
}
@BeforeMethod
public void setUp() throws Exception {
// set up appium
// JSONObject obj = new JSONObject(" .... ");
// String pageName = obj.getJSONObject("pageInfo").getString("pageName");
//
// JSONArray arr = obj.getJSONArray("posts");
// for (int i = 0; i < arr.length(); i++)
// {
// String post_id = arr.getJSONObject(i).getString("post_id");
// }
DesiredCapabilities capabilities = new DesiredCapabilities();
//real device
// capabilities.setCapability("deviceName", "iPad");
// capabilities.setCapability("udid","c0ff732e91bae98e61a11ce056dd727f30f5a2ae");
// capabilities.setCapability("bundleid", "com.anghami.anghami");
// capabilities.setCapability("ipa", "/Users/MacBookair2014/Desktop/Anghami.ipa");
//simulator
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.4");
capabilities.setCapability("deviceName", "iPhone 5");
capabilities.setCapability("app", "/Users/MacBookair2014/Desktop/Anghami.app");
driver = new IOSDriver<WebElement>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
JavascriptExecutor js = (JavascriptExecutor)driver;
startRecording();
driver.findElement(By.name("Let's start!")).click();
driver.findElement(By.name("Email Login")).click();
// System.out.println(driver.findElementByIosUIAutomation("applications()[1].windows()[1].textFields()[1]").getAttribute("value"));
driver.findElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]").sendKeys("roygeagea@gmail.com");
driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIASecureTextField[1]")).sendKeys("royanghami");
driver.findElement(By.name("Login")).click();
// if(driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[8]")) != null)
// {
// driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[8]")).click();
// }
Thread.sleep(15000);
// js.executeScript("mobile: scrollTo", new HashMap() {{ put("element", driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[2]/UIATableCell[5]")).getId()); }});
// driver.findElement(By.name("Menu Menu")).click();
// driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[5]")).click();
//not functional on sim and real
// HashMap scrollObject = new HashMap();
// scrollObject.put("direction", "down");
// js.executeScript("mobile: scroll", scrollObject);
//not functional on sim and real
driver.swipe(100,500,100,100,900);
//not functional on sim and real
// HashMap swipeObject = new HashMap ();
// swipeObject.put("startX", 172);
// swipeObject.put("startY", 502);
// swipeObject.put("endX", 172);
// swipeObject.put("endY", 170);
// swipeObject.put("duration", 2000);
// js.executeScript("mobile: swipe", swipeObject);
//not functional on sim and real
// HashMap swipeObject = new HashMap();
// swipeObject.put("element", "Editors' Choice");
// js.executeScript("mobile: scrollTo", swipeObject);
driver.scrollTo("Editors' Choice");
stopRecording();
driver.close();
System.out.println("App launched");