I'm using Android real device (samsung tablet SM-T531),Android version 5.0.2. Appium server(1.4.16)version and Eclipse Java EE IDE for Web Developers(Neon Release-4.6.0) in windows 10 OS. Using Android Device Monitor(25.2.2 ) identify the resource-id of contents.
I'm facing one issue while testing in hybrid apps. An apk considered a form with two fields in same row. I'm selecting by using resource-id of the 2nd field instead of a row. But it positioning the 1st field of row.
in that im selecting Airline using resourceid . But it selecting the sector field.
package winaim;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;
import io.appium.java_client.android.AndroidDriver;
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.remote.DesiredCapabilities;
public class winaimlandscape {
private AndroidDriver driver;
@BeforeTest
public void before() throws Exception {
//File appDir = new File("C://Users//SYS//Downloads//new//android//Android//sdk//platform-tools");
//File app = new File(appDir, "OneViewMobil.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","1bdc4e3e07561979");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("appPackage","org.winaim.oneview.Live");
capabilities.setCapability("appActivity", ".OneViewMobile");
//capabilities.setCapability("app", app.getAbsolutePath());
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
}
@Test(priority=1)
public void register() throws InterruptedException
{
//register
//driver.findElement(By.xpath("//android.widget.Button[@bounds='[20,716][700,810]']")).click();//button
//signin
driver.findElement(By.xpath("//android.widget.Button[@content-desc='SIGN IN ']")).click();//signin
}
@Test(priority=3)
public void settings()throws InterruptedException{
//my settings
driver.findElement(By.xpath("//android.view.View[@bounds='[0,30][42,64]']")).click();//menu
driver.findElement(By.xpath("//android.view.View[@bounds='[0,373][267,429]']")).click();//settings
driver.findElement(By.xpath("//android.view.View[@bounds='[0,220][1280,274]']")).click();//temperature
//ok
driver.findElement(By.id("android:id/button3")).click();//ok
//cancel
//driver.findElement(By.id("android:id/button2")).click();//cancel
Thread.sleep(5000);
}
@Test(priority=7)
public void myaudits()throws InterruptedException{
//menu
driver.findElement(By.xpath("//android.view.View[@bounds='[0,30][42,64]']")).click();//menu
//audits
Thread.sleep(5000);
driver.findElement(By.xpath("//android.view.View[@bounds='[0,257][267,313]']")).click();//audits
}
@Test(priority=8)
public void newDC()throws InterruptedException{
//select new
Thread.sleep(5000);
driver.findElement(By.xpath("//android.view.View[@content-desc=' New DC']")).click();//newDC
driver.findElement(By.xpath("//android.view.View[@content-desc='Start']")).click();//start
Thread.sleep(5000);
}
@Test(priority=10, invocationCount = 10)
public void validentries1()throws InterruptedException{
//Thread.sleep(5000);
//product
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"Column_89\")").click();
//Thread.sleep(2000);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"txtAutoCompleteSearch\")").sendKeys("abcd");
//Thread.sleep(2000);
driver.findElement(By.xpath("//android.view.View[@bounds='[668,336][1280,385]']")).click();//add
//Thread.sleep(2000);
//Blast Temp
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"ATBlastChillerTempInControlId\")").click();
Thread.sleep(2000);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"ATBlastChillerTempInControlId\")").sendKeys("29");
Thread.sleep(2000);
//blast chiller number
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AddlBlastChillerNoControlId\")").click();
Thread.sleep(2000);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"2392\")").click();
//Thread.sleep(5000);
//baking
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"txtCoreTempControlId\")").click();
Thread.sleep(2000);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"txtCoreTempControlId\")").sendKeys("43");
Thread.sleep(2000);
//customer details
//sector
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AddlSectorControlId\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"283869\")").click(); //003
//Airline
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AddlFlightControlId\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"313\")").click();
//flight
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AddlAirlineControlId\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"240912\")").click();
Thread.sleep(2000);
//F&B&other
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AddlFAndBControlId\")").click();
Thread.sleep(2000);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"519737\")").click();
//Thread.sleep(2000);
//Temp Out
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"ATBlastChillerTempOutControlId\")").click();
//Thread.sleep(2000);
//ok
driver.findElement(By.id("android:id/button1")).click();//ok
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"ATBlastChillerTempOutControlId\")").sendKeys("5");
//Comments
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"AddlCommentControlId\")").sendKeys("completed");
//save
driver.findElement(By.xpath("//android.view.View[@bounds='[405,1033][592,1080]']")).click();//save&submit
//ok
driver.findElement(By.id("android:id/button1")).click();//ok
Thread.sleep(3000);
}
@Test(priority=21)
public void logoutt()throws InterruptedException{
Thread.sleep(2000);
driver.findElement(By.xpath("//android.view.View[@bounds='[1247,31][1271,63]']")).click();//logout
//ok
driver.findElement(By.id("android:id/button1")).click();//ok
//cancel
//driver.findElement(By.id("android:id/button2")).click();//cancel
}
@AfterTest
public void after() throws Exception {
driver.quit();
//driver.wait(15000);
}
}