1

Can anybody help me,

I have been try to test hybrid application (developed in kony ide) using appiumbut the coding not executed .then using UIautomator viewer I didn't get "resource id " so im using by.name method. is der any possibility to get resource id?? then how to make work with hybrid application .

My coding

package com.appium.testcase;


import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver
public class AppiumTest 
{   
WebDriver driver=null;

@BeforeClass
public void setup() 
{
File appDir = new File("E:/Automation/adt-bundle-windows-x86_64-20130514/sdk");
File app = new File(appDir, "WatsCooking.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device","Android");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(CapabilityType.VERSION, "5.1");// motoe
//capabilities.setCapability(CapabilityType.VERSION, "4.2.1");//lava
capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");

capabilities.setCapability("app-Package","com.truetech.watcooking");
//Here we mention the activity name, which is invoked initially as app's first page.
capabilities.setCapability("app-Activity","com.truetech.watscooking.SplashActivity");

capabilities.setCapability("deviceName", "ZX1B328HPW");//motoe
//capabilities.setCapability("deviceName", "0123456789ABCDEF");//lava
capabilities.setCapability("app", app.getAbsolutePath());

try {
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);  

     }

     @Test
public void loginTest() throws Exception {  

    try{
        System.out.println("call");
        List <WebElement> loginbt =driver.findElements(By.id("btnlogin" ));
        loginbt.get(1).click();         
  }  

          catch(NullPointerException ex1)
    {

              //System.out.println( "Value not found in Dropdown to Select");


    }

     }
@AfterMethod
public void tearDown() {
           driver.quit();
    }
}
Dhak
  • 11
  • 2

1 Answers1

-1

You need to expose widget IDs. Do the following:

  • On the File menu, click Settings. The Project Settings dialog box displays.
  • Click the Native tab.
  • On the Common sub-tab, click Expose Widget IDs for Test Automation, and then click Finish.

For the Android platform, when you select to expose widget IDs, an xml file is generated during the build containing the widget IDs of the app. This is explained in detail under Android Limitations.

See the docs for more information.

Tom Aranda
  • 5,919
  • 11
  • 35
  • 51
Jennifer Elyse
  • 143
  • 1
  • 9
  • To expose the widget IDs, do the following: On the File menu, click Settings. The Project Settings dialog box displays. Click the Native tab. On the Common sub-tab, click Expose Widget IDs for Test Automation, and then click Finish. For the Android platform, when you select to expose widget IDs, an xml file is generated during the build containing the widget IDs of the app. This is explained in detail under Android Limitations. – Jennifer Elyse Dec 06 '17 at 16:25