title: Selenium Webdriver: Click video control play button
body: <p>How can I click the play button within video controls on the video located on this page?  <a href="http://prolifiq.com/inside-prolifiq/tiles/invite/" rel="nofollow">http://prolifiq.com/inside-prolifiq/tiles/invite/</a></p>
  
  <p>Below is the page source.  I do see what looks like a javascript 'playpause' control but I'm not sure how to click it.</p>
  
  <pre><code>&lt;div id="videoModal" class="reveal-modal expand open" style="display: block; opacity: 1; visibility: visible; top: 100px;"&gt;
  &lt;video id="wp_mep_1" width="709" height="540" preload="none" controls="controls" poster="http://prolifiq.com/wp-content/themes/prolifiq/img/bgr-video.png"&gt;
  &lt;source type="video/mp4" src="http://prolifiq.com/wp-content/themes/prolifiq/videos/Prolifiq-Invite.mp4"&gt;&lt;/source&gt;
  &lt;source type="video/webm" src="http://prolifiq.com/wp-content/themes/prolifiq/videos/Prolifiq-Invite.webm"&gt;&lt;/source&gt;
  &lt;object width="709" height="540" data="http://prolifiq.com/wp-content/plugins/media-element-html5-video-and-audio-player/mediaelement/flashmediaelement.swf" type="application/x-shockwave-flash"&gt;
  &lt;/video&gt;
  &lt;script type="text/javascript"&gt;
  jQuery(document).ready(function($) {
  $('#wp_mep_1').mediaelementplayer({
  m:1
  ,features: ['playpause','current','progress','duration','volume','tracks','fullscreen']
  });
  });
  &lt;/script&gt;
  &lt;a class="close-reveal-modal"&gt;×&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am able close the video by clicking the "x" button in the player's upper right using xpath.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>import java.util.List;
  import java.util.regex.Pattern;
  import java.util.concurrent.TimeUnit;
  
  import org.junit.*;
  
  import static org.junit.Assert.*;
  import static org.hamcrest.CoreMatchers.*;
  
  import org.openqa.selenium.*;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.support.ui.Select;
  
  public class prolifictestscript {
    private WebDriver driver;
    private String baseUrl;
    private boolean acceptNextAlert = true;
    private StringBuffer verificationErrors = new StringBuffer();
  
    @Before
    public void setUp() throws Exception {
      driver = new FirefoxDriver();
      baseUrl = "http://prolifiq.com";
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }
  
    @Test
    public void testProlifictestscript() throws Exception {
      driver.get(baseUrl + "/");
      driver.findElement(By.xpath(".//*[@id='menu-item-1905']/a")).click();//click menu
      driver.findElement(By.linkText("Tiles")).click();//click sub menu
      driver.findElement(By.xpath("html/body/section[1]/div[2]/ul/li[5]/a")).click();//click invite tile
      List&lt;WebElement&gt; downloadHeader = driver.findElements(By.xpath("//h1[text() = 'Invite']"));//verify h1 invite exists
      if(downloadHeader.size() &gt; 0)
      {
          System.out.println("Found h1 header Invite");
      }
  
      driver.findElement(By.xpath("html/body/section[1]/div/a/img")).click();//click movie box
  
      //driver.findElement(By.xpath(".//*[@id='videoModal']")).click();//.//*[@id='videoModal']//not working
      Thread.sleep(49000);//wait 49 seconds for video to end
      driver.findElement(By.xpath(".//*[@id='videoModal']/a")).click();//click x button
    }
  
    @After
    public void tearDown() throws Exception {
      //driver.quit();
      String verificationErrorString = verificationErrors.toString();
      if (!"".equals(verificationErrorString)) {
        fail(verificationErrorString);
      }
    }
  
    private boolean isElementPresent(By by) {
      try {
        driver.findElement(by);
        return true;
      } catch (NoSuchElementException e) {
        return false;
      }
    }
  
    private boolean isAlertPresent() {
      try {
        driver.switchTo().alert();
        return true;
      } catch (NoAlertPresentException e) {
        return false;
      }
    }
  
    private String closeAlertAndGetItsText() {
      try {
        Alert alert = driver.switchTo().alert();
        String alertText = alert.getText();
        if (acceptNextAlert) {
          alert.accept();
        } else {
          alert.dismiss();
        }
        return alertText;
      } finally {
        acceptNextAlert = true;
      }
    }
  }
  </code></pre>