package edu.wm.translationengine.appium;

import org.openqa.selenium.By;

import edu.wm.translationengine.classes.*;
import edu.wm.translationengine.trans.GenericFunctions;
import io.appium.java_client.MobileElement;


public class AppiumFunctions extends GenericFunctions{


	public void appium_switcher(String action, StepTestCase s){
		
		if(action.equals("CLICK")){
			//pull component 
			String name = s.getComponent().getText();
			//format string
			String format = "\t\t\tdriver.findElement(By.name(\""+name+"\")).click();\n"
					+ "\t\t\tThread.sleep(250);\n";
			//write string to file
			AppiumTranslator.toWrite.add(format);
		
		}
		if(action.equals("LONG_CLICK")){
			//pull component 
			String name = s.getComponent().getText();
			//format string
			String format = "\t\t\t((MobileElement)driver.findElement(By.name(\""+name+"\"))).tap(1, 800);\n"
					+"\t\t\tThread.sleep(250);\n";
			AppiumTranslator.toWrite.add(format); 			
		}
		//TODO: add typing?
	}	
	
}

@@ -983,27 +983,360 @@
 %0D%0A%09%09
-//TODO: add typing?
+%0D%0A%09%09if(action.equals(%22TYPE%22))%7B%0D%0A%09%09%09//pull component ID%0D%0A%09%09%09String id = s.getComponent().getId();%0D%0A%09%09%09String typingtext = s.getComponent().getText();%0D%0A%09%09%09//format string%0D%0A%09%09%09String format = %22%5Ct%5Ct%5Ctdriver.findElement(By.id(%5C%22%22+id+%22%5C%22)).sendkeys(%22+typingtext+%22);%5Cn%22%0D%0A%09%09%09%09%09+ %22%5Ct%5Ct%5CtThread.sleep(250);%5Cn%22;%0D%0A%09%09%09AppiumTranslator.toWrite.add(format);%0D%0A%09%09%09%0D%0A%09%09%7D
 %0D%0A%09%7D

Update AppiumFunctions.java