title: Appium android driver
body: <pre><code>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.junit.Test;
  import org.openqa.selenium.By;
  import org.openqa.selenium.JavascriptExecutor;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.openqa.selenium.remote.RemoteWebDriver;
  
  import android.provider.Browser;
  import android.test.ActivityInstrumentationTestCase2;
  
  import com.example.secretsanta.MainActivity;
  
  public class AppiumExampleTest extends ActivityInstrumentationTestCase2&lt;MainActivity&gt; {
  
      private RemoteWebDriver driver;
  
      public AppiumExampleTest(Class &lt;MainActivity&gt; activityClass) {
          super(activityClass);
      }
  
      @Before
      public void setup() throws MalformedURLException {
          File appDir = new File("../secret_santa//bin");
          File app = new File(appDir, "secret_santa.apk");
  
          DesiredCapabilities caps = new DesiredCapabilities();
          caps.setCapability("version", "5");
          caps.setCapability("device", "emulator-5554");
          caps.setCapability("platform", "ANDROID");
          caps.setCapability("browser", "CHROME");
          caps.setCapability("app-package", "com.example.secretsanta");
          caps.setCapability("app-activity", "MainActivity.class");
          caps.setCapability("app", app.getAbsolutePath());
  
  
              driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
  
  
          driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
  
      }
  
      @Test
      public void testAppiumExample() throws Exception {
  
          // find button with label or content-description "Button 1"
  
          driver.findElement(By.id("createListButton")).click();
  
          // click on button and start second Activity
  
          // we are on second screen now
          // check if second screen contains element with text “Activity2”
          driver.findElement(By.id("createListView"));
  
          // click back button
          HashMap&lt;String, Integer&gt; keycode = new HashMap&lt;String, Integer&gt;();
          keycode.put("keycode", 4);
          ((JavascriptExecutor) driver).executeScript("mobile: keyevent", keycode);
          //
          // // we are again in main activity
          driver.findElement(By.id("createListButton"));
      }
  
      @After
      public void tearDown() {
          if (driver != null) {
              driver.quit();
          }
      }
  
  }
  </code></pre>
  
  <p>I am trying to press the button and then go to the next activity and then return to the main activity. At the moment I have a few errors, one with the actvityinstrumentationtestcase2 and then the constructor and then another with the element.</p>