Appium automation testing using real android device

45 views
Skip to first unread message

LACHU LAC

unread,
Aug 16, 2017, 1:52:02 AM8/16/17
to appium-developers
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. 

Im enclosed screenshot of form. 

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 = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
 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);
}

}

dump_8723519644807634826.png

Telmo Cardoso

unread,
Aug 16, 2017, 3:19:11 AM8/16/17
to appium-developers
  1. Update Appium version
  2. Use https://discuss.appium.io/ for any doubts about appium
  3. Report issues you found on https://github.com/appium/appium/issues

LACHU LAC

unread,
Aug 16, 2017, 3:45:46 AM8/16/17
to appium-developers
Already running the newer version only...... for windows10 ... Appium latest version is 1.4.16.1
appiumversion.png

Telmo Cardoso

unread,
Aug 16, 2017, 4:00:54 AM8/16/17
to appium-developers
Latest version is appium 1.6.5. If you want to continue to use a GUI version, then please download from here:

LACHU LAC

unread,
Aug 16, 2017, 11:11:13 AM8/16/17
to appium-developers
I am facing issue on Appium  Android Hybrid app(HTML page) while take resource Id.

Using resourceId setting value in second field of first row,always getting an error "**element not available**" (what i observe it while selecting second field ,control position is moved first first field of row)

**Note: if setting the value with one control with each row always working fine**


This is my code to take the resource Id :   

   

     driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"txtSecondName\")").sendKeys("Sam");
    driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"txtSecondName\")").click();

Please find by Software infos

Appium Version : 1.4.16
OS : Winfopw 10 
**Testing Device**<br/>
Android Tablet<br/>
OS: Android 5.0.2 <br/>
Device: Samsung -Galaxy Tab 4 (SM-T531)



appiumversion.png
Reply all
Reply to author
Forward
0 new messages