Hi I created a code using Java that allows Appium to test my app. Basically my app will open the gmail and the user has to click on send button. I'm trying to use Appium to click on send button automatically but it's not working. Here is the code I created
package Appium;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class StartApplication {
@Test
public void testLoginFB() throws MalformedURLException, InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities() ;
//capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformnName","Android");
capabilities.setCapability("platformVersion","7.0");
capabilities.setCapability("deviceName","Lucas" );
capabilities.setCapability("udid", "5210ce98fa7eb4b3");
//capabilities.setCapability("app","C:\\Users\\lucas\\Downloads\\TED.apk");
capabilities.setCapability("appPackage","AppDeTeste.Android");
capabilities.setCapability("appActivity", "md52847d06e6d7656d51426984702f9ce17.MainActivity");
AndroidDriver driver = new AndroidDriver (new URL("http://0.0.0.0:4723/wd/hub"),capabilities) ;
driver.manage().timeouts().implicitlyWait(10000,TimeUnit.SECONDS);
driver.findElement(By.id("spnSou")).click();
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\"lucas_m_santos@whirlpool.com\").instance(0))").click();
driver.findElement(By.id("spnDados")).click();
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\"jefferson_s_pecanha@whirlpool.com\").instance(0))").click();
//driver.findElement(By.id("acursio_maia@whirlpool.com")).click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AppDeTeste.Android:id/rdbTerPaixao\").text(\"Ter Paixão\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AppDeTeste.Android:id/rdbUmaWhirlpool\").text(\"Uma só Whirlpool\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AppDeTeste.Android:id/rdbSeroDono\").text(\"Ser o dono\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AppDeTeste.Android:id/rdbEspiritoDeVitoria\").text(\"Espírito de vitória\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AppDeTeste.Android:id/rdbEspiritoDeVitoria\").text(\"Espírito de vitória\")").click();
driver.findElement(By.id("edtComentario")).click();
driver.findElement(By.id("edtComentario")).sendKeys("Testando a ferramenta Appium");
driver.pressKeyCode(AndroidKeyCode.BACK);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AppDeTeste.Android:id/button1\").text(\"RECONHECER\")").click();
testSentemail();
Thread.sleep(8000);
}
public void testSentemail() throws MalformedURLException, InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities() ;
//capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformnName","Android");
capabilities.setCapability("platformVersion","7.0");
capabilities.setCapability("deviceName","Lucas" );
capabilities.setCapability("udid", "5210ce98fa7eb4b3");
//capabilities.setCapability("app","C:\\Users\\lucas\\Downloads\\TED.apk");
capabilities.setCapability("appPackage","com.google.android.gm");
capabilities.setCapability("appActivity", "com.google.android.gm.ComposeActivityGmailExternal");
AndroidDriver driver = new AndroidDriver (new URL("http://0.0.0.0:4723/wd/hub"),capabilities) ;
driver.manage().timeouts().implicitlyWait(10000,TimeUnit.SECONDS);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.google.android.gm:id/send\")").click();
Thread.sleep(8000);
}
}
How can I use Java and appium to send this e-mail? Should I change any parameter or am I missing anything?
Regards,
Aucun commentaire:
Enregistrer un commentaire