mobile - Im using Appium for Android Automation. Android app is closing while debugging the code. -
i have written below code opening app , clicking on link on app. when debugging code android app closing unexpectedly. when trying verify elements in list in debug mode saw app getting closed on mobile. please find code below:
file classrootpath = new file(system.getproperty("user.dir")); file appdir = new file(classrootpath, "//apps//"); file app = new file(appdir, "base.apk"); desiredcapabilities capabilities = new desiredcapabilities(); capabilities.setcapability(capabilitytype.browser_name, ""); capabilities.setcapability(mobilecapabilitytype.device_name, "xt1033"); capabilities.setcapability(mobilecapabilitytype.platform_version, "5.0.2"); capabilities.setcapability(mobilecapabilitytype.platform_name, "android"); capabilities.setcapability(mobilecapabilitytype.app, app.getabsolutepath()); capabilities.setcapability(mobilecapabilitytype.app_package, "com.bt.bms"); capabilities.setcapability(mobilecapabilitytype.app_activity, "com.bt.bms.activities.maintabactivity"); androiddriver<webelement> driver = new androiddriver<webelement>( new url("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlywait(80, timeunit.seconds); thread.sleep(5000); list<webelement> elements = driver.findelements(by.id("tabtext")); system.out.println(elements.size()); system.out.println(elements.get(2).gettext()); elements.get(2).click(); driver.closeapp(); }
yes, because clicks fast , have driver.closeapp();
right after makes close fast. put wait command after click();
, work fine.
Comments
Post a Comment