I am new to Appium, In my code I have given required desired capabilities and wrote test case that is working fine. I tired each scenario (eg login,Mobile recharge etc…)in separate class . Test cases in a login page into different functions and provide function names in alphabetical order… can i know i was doing my scrpting in correct format
Code i tried is given below
package ********;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.ElementNotVisibleException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest; //@AfterTest annotated method will be executed when all @Test annotated methods completed its execution
import org.testng.annotations.BeforeTest; //@Before Test annotated method will be executed before any @Test method
import org.testng.annotations.Test; //@Test annotation describes method as a test method or part of your test
public class Login {
//WebDriver driver;
AndroidDriver driver;
Dimension size;
//Setup to Launch the app
@BeforeTest
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "0123456789ABCDEF");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability(CapabilityType.VERSION, "5.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "*******");
capabilities.setCapability("appActivity", "com.********e");
capabilities.setCapability("unicodekeyboard", true);
capabilities.setCapability("resetkeyboard", true);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver, 3047230);
wait.until(ExpectedConditions.elementToBeClickable(By.className("android.widget.FrameLayout")));
}
//Login Starts
/*--------------------------Select the language and click on Login Starts-----------------*/
//Select Language,click on login redirect to Login page
@Test
public void T1a_Landingpage() {
driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-21')]")).click(); //Open drop down menu
driver.findElement(By.name("English")).click(); //Select from drop down
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-element-26')]")).click();
}
/*--------------------------Select the language and click on Login Ends--------------------*/
/*--------------------------------Login details page Starts---------------------------------*/
//Click on Help content in Login page
@Test
public void T1b_HelpContent() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'fedhelpbtncontainer')]")).click();
driver.findElement(By.xpath("//android.view.View[@content-desc='OK']")).click();
}
//Enter Mobile Number, Account number and Pin
@Test
public void T1c_Enterdetails() {
//driver.findElement(By.xpath("//android.widget.EditText[@text='Mobile Number']")).sendKeys("8129497946");
//driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-65')']")).click();
driver.findElement(By.name("Account Number")).sendKeys("15125000213700");
driver.hideKeyboard();
driver.findElement(By.name("PIN")).sendKeys("1234");
driver.hideKeyboard();
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-6')]")).click();
}
/*--------------------------------Login details page Ends------------------------------*/
/*--------------------------------Activate page Starts---------------------------------*/
//Click to Activate
@Test
public void T1d_Activate() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-7')]")).click();
}
/*--------------------------------Activate page Ends---------------------------------*/
/*--------------------------------Enter pin Starts---------------------------------*/
//Enter 4 digit pin to login
@Test
public void T1e_Login() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-1')]")).sendKeys("1234");
}
/*--------------------------------Enter pin Ends---------------------------------*/
//Login End
@AfterTest
public void End() {
System.out.println("End");
driver.quit();
}
}