I am new in automation testing . I am trying to find elements in webview in Android app using appium . Below is code i am using but I am not able to find say div using its id .
I am using latest appium for destop on windows and latest jars . Please help
private AppiumDriver driver;
–Before
public void setUp() throws Exception {
// set up appium
}
–After
public void tearDown() throws Exception {
driver.quit();
}
—Test
public void webView() throws InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("appPackage", "com.hokucampusaffairs");
capabilities.setCapability("appActivity", "com.mybeeps.DashboardActivity");
try {
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread.sleep(6000);
Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains(“WEBVIEW”)){
driver.context(contextName);
}
}
String pagesource= driver.getPageSource();
String url= driver.getCurrentUrl();
try {
WebElement inputField = driver.findElement(By.id(“top-container”));
inputField.click();
}
catch(Exception e)
{
e.printStackTrace();
}
}