ui automation - Appium android settings -


i unable test simple app on device using appium error shown below. weirdest thing similar error shown when not connecting device. struck @ place long time. have done pre-conditions required this. have attached images android settings in appium tool please me! code

package com.sasken;  import io.appium.java_client.android.androiddriver; import io.appium.java_client.remote.mobilecapabilitytype;  import java.io.file; import java.net.malformedurlexception; import java.net.url; import java.util.hashmap; import java.util.concurrent.timeunit;  import org.junit.after; import org.junit.before; import org.openqa.selenium.by; import org.openqa.selenium.javascriptexecutor; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.remote.desiredcapabilities; import org.testng.annotations.test;  public class appiumtestingapp {     private androiddriver driver ;  @before public void setup() {      string apk_path = system.getproperty("user.dir")             + "/apkfile/testedandroidapp.apk";      //  file appdir = new file("..//testedandroidapp//bin//");     //file app = new file(appdir, "testedandroidapp.apk");      desiredcapabilities capabilities = new desiredcapabilities();     capabilities.setcapability("appium-version", "1.0");     capabilities.setcapability(mobilecapabilitytype.platform_name, "android");     capabilities.setcapability(mobilecapabilitytype.platform_version, "5.0.2");     capabilities.setcapability(mobilecapabilitytype.app, apk_path);                  capabilities.setcapability(mobilecapabilitytype.device_name, "zx1d63hd35");     capabilities.setcapability(mobilecapabilitytype.app_package, "com.sasken");     capabilities.setcapability(mobilecapabilitytype.app_activity, "mainactivity");     //capabilities.setcapability(capabilityconstants.app, app.getabsolutepath());      try {         driver = new androiddriver(new url("http://127.0.0.1:4723/wd/hub"), capabilities);     } catch (malformedurlexception e) {         e.printstacktrace();     }      driver.manage().timeouts().implicitlywait(80, timeunit.seconds); }  @test public void appiumexampletest() throws exception {     // find button label or content-description "button 1"     //  system.out.println(driver.findelement(by.name("hello world!")));     webelement button=driver.findelement(by.name("button1"));     //  system.out.println("button:"+button);      // click on button , start second activity     button.click();      // on second screen     // check if second screen contains textview text “activity2”     driver.findelement(by.name("activity2"));      // click button     hashmap<string, integer> keycode = new hashmap<string, integer>();     keycode.put("keycode", 4);     ((javascriptexecutor) driver).executescript("mobile: keyevent", keycode);      // again in main activity     driver.findelement(by.name("button1")); }  @after public void teardown() {     if (driver != null) {         driver.quit();     } } 

}

the error given below

[testng] running: c:\users\zamir\appdata\local\temp\testng-eclipse--1778615093\testng-     customsuite.xml  failed: appiumexampletest java.lang.nullpointerexception  @    com.sasken.appiumtestingapp.appiumexampletest(appiumtestingapp.java:56) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.testng.internal.methodinvocationhelper.invokemethod(methodinvocationhelper.java:84) @ org.testng.internal.invoker.invokemethod(invoker.java:714) @ org.testng.internal.invoker.invoketestmethod(invoker.java:901) @ org.testng.internal.invoker.invoketestmethods(invoker.java:1231) @ org.testng.internal.testmethodworker.invoketestmethods(testmethodworker.java:127) @ org.testng.internal.testmethodworker.run(testmethodworker.java:111) @ org.testng.testrunner.privaterun(testrunner.java:767) @ org.testng.testrunner.run(testrunner.java:617) @ org.testng.suiterunner.runtest(suiterunner.java:334) @ org.testng.suiterunner.runsequentially(suiterunner.java:329) @ org.testng.suiterunner.privaterun(suiterunner.java:291) @ org.testng.suiterunner.run(suiterunner.java:240) @ org.testng.suiterunnerworker.runsuite(suiterunnerworker.java:52) @ org.testng.suiterunnerworker.run(suiterunnerworker.java:86) @ org.testng.testng.runsuitessequentially(testng.java:1224) @ org.testng.testng.runsuiteslocally(testng.java:1149) @ org.testng.testng.run(testng.java:1057) @ org.testng.remote.remotetestng.run(remotetestng.java:111) @ org.testng.remote.remotetestng.initandrun(remotetestng.java:204) @ org.testng.remote.remotetestng.main(remotetestng.java:175)   ===============================================   default test   tests run: 1, failures: 1, skips: 0 ===============================================   =============================================== default suite total tests run: 1, failures: 1, skips: 0 ===============================================  [testng] time taken org.testng.reporters.xmlreporter@3c03e1: 171 ms [testng] time taken org.testng.reporters.jq.main@53c155: 77 ms [testng] time taken [failedreporter passed=0 failed=0 skipped=0]: 34 ms [testng] time taken org.testng.reporters.junitreportreporter@14cda3: 10 ms [testng] time taken org.testng.reporters.suitehtmlreporter@1ffba4f: 96 ms [testng] time taken org.testng.reporters.emailablereporter2@608423: 8 ms 

also,i recommend place following method in base class , use everywhere in order perform action:

    public void clickback(){         driver.sendkeyevent(4); } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -