title: Example of touch event with webdriver python?
body: <p>I have seen about 100 <a href="http://android-developers.blogspot.com/2011/10/introducing-android-webdriver.html" rel="noreferrer">touch event examples for the Java webdriver</a> online, but not a single one for python. 
  Would someone be so kind as to post one here, so it saves people many hours of search?
  Here is my attempt to do a basic double_tap on an element in an android simulator in order to zoom in on it. Much thanks</p>
  
  <p>EDIT: Thanks to Julian's help I was able to figure out the missing link: for some reason, the touch actions require an extra <em>.perform()</em> at the end. Below you will find a bunch of touch events in action--and the code is cleaner. Enjoy!</p>
  
  <pre><code>import unittest, time
  from selenium import webdriver
  
  print "Here are our available touch actions (ignore the ones that look like __xx__): ", dir(webdriver.TouchActions)
  #print dir(webdriver)
  
  
  
  class Test(unittest.TestCase):
  
  
      def setUp(self):
          self.driver = webdriver.Remote(command_executor='http://localhost:8080/wd/hub',  desired_capabilities=webdriver.DesiredCapabilities.ANDROID)
          self.touch =webdriver.TouchActions(self.driver)
  
          #self.driver = TouchActions(self.driver)
          #self.driver = webdriver.Firefox()
          self.driver.implicitly_wait(30)
  
  
      def testHotmail(self):
          self.driver.get("http://www.hotmail.com")
  
          elem=self.driver.find_element_by_css_selector("input[name='login']")
          #tap command
          self.touch.tap(elem).perform()
          time.sleep(2)
          elem.send_keys("hello world")
          time.sleep(2)
          #double tap
          self.touch.double_tap(elem).perform()
          time.sleep(2)
  
          #testing that regular webdriver commands still work
          print self.driver.find_element_by_partial_link_text("Can't access").text
  
          elem= self.driver.find_element_by_css_selector("input[type='submit']")
          self.touch.tap(elem).perform()
          time.sleep(3)
  
  
  
  
      def tearDown(self):
  
          time.sleep(3)
  
          try:
              self.driver.quit()
          except Exception:
              print(" TearDown Method: Browser seems already closed.")
  
          pass
  
  
  if __name__ == "__main__":
      unittest.main()
  </code></pre>
  
  <p>Here is an original Java Example:</p>
  
  <pre><code>WebElement toFlick = driver.findElement(By.id("image"));
  // 400 pixels left at normal speed
  Action flick = getBuilder(driver).flick(toFlick, 0, -400, FlickAction.SPEED_NORMAL)
          .build();
  flick.perform();
  WebElement secondImage = driver.findElement(“secondImage”);
  assertTrue(secondImage.isDisplayed());
  </code></pre>