Hi,
I am new to appium learning and trying to write simple code for test automation. One query i have is that when I try to, say, automate the dialing of a number from phone, i can either use layouts like this:
driver=new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilites);
WebElement linearLayout=driver.findElement(By.id("com.android.contacts:id/dialpad"));
linearLayout.findElement(By.id("com.android.contacts:id/nine")).click();
or I can simply call find element function from AppiumDriver objects like this:
driver=new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities); dr.findElement(By.id("com.android.dialer:id/one")).click();
My question is that which approach is better in terms of coding best practices? How does use of elements like layout make a difference while writing tests like these?