package test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileBy;
import io.appium.java_client.ios.IOSDriver;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

/**
 *
 * 
 * @author Feliks Rozenberg frozenbe@alumni.uwo.ca
 */
@SuppressWarnings("deprecation")
public class SimpleAppiumTest {

	private AppiumDriver<WebElement> driver;

	@Before
	public void setUp() throws Exception {
		// set up appium
		File appDir = new File(System.getProperty("user.dir"), "TestApps");
		File app = new File(appDir, "PocketForecast.app");
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("platformVersion", "9.0");
		capabilities.setCapability("deviceName", "iPhone 5");
		capabilities.setCapability("app", app.getAbsolutePath());
		driver = new IOSDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
	}

	@After
	public void tearDown() throws Exception {
		driver.quit();
	}

	@Test
	public void testLaunch() throws Exception {

	}

}

@@ -1264,73 +1264,98 @@
 m%0A%09%09
-File appDir = new File(System.getProperty(%22user.dir%22), %22TestApps%22
+String appPath = System.getProperty(%22appPath%22);%0A%09%09System.out.println(%22appPath: %22 + appPath
 );%0A%09
@@ -1382,36 +1382,16 @@
 (app
-Dir, %22PocketForecast.app%22
+Path
 );%0A
+%0A
 %09%09De
@@ -1503,11 +1503,11 @@
 %22, %22
-9.0
+8.1
 %22);%0A
@@ -1561,9 +1561,9 @@
 one 
-5
+6
 %22);%0A
@@ -1819,35 +1819,801 @@
 test
-Launch() throws Exception %7B
+SignInValidCreds() throws Exception %7B%0A%0A%09%09Thread.sleep(3000);%0A%09%09// Fill in and submit%0A%09%09driver.findElement(By.xpath(%22//UIAApplication%5B1%5D/UIAWindow%5B1%5D/UIAElement%5B1%5D/UIAScrollView%5B1%5D/UIATextField%5B1%5D%22))%0A%09%09%09%09.sendKeys(%22feliks.rozenberg@universe.com%22);%0A%09%09Thread.sleep(1000);%0A%09%09driver.findElement(%0A%09%09%09%09By.xpath(%22//UIAApplication%5B1%5D/UIAWindow%5B1%5D/UIAElement%5B1%5D/UIAScrollView%5B1%5D/UIASecureTextField%5B1%5D%22))%0A%09%09%09%09.sendKeys(%22uniiverse%22);%0A%09%09driver.findElement(MobileBy.AccessibilityId(%22Sign In%22)).click();%0A%09%09Thread.sleep(3000);%0A%0A%09%09// Allow camera%0A%09%09driver.switchTo().alert().accept();%0A%09%09Thread.sleep(5000);%0A%0A%09%09// Switch tab%0A%09%09driver.findElement(MobileBy.AccessibilityId(%22Sell%22)).click();%0A%09%09Thread.sleep(5000);%0A%0A%09%09assertTrue(driver.findElement(MobileBy.AccessibilityId(%22Synthetic Free Listing%22)).isDisplayed());
 %0A%0A%09%7D

Add a sign in test