title: In Java w/Selenium WebDriver, how to I click link on overlay ad using JavaScript only when ad shows?
body: <p>I am a newbie to automation and am trying to automate some websites using Java w/Selenium WebDriver. Users with no cookies are presented an interstitial Ad served via JavaScript that overlays the screen. The Ad has a "Skip this advertisement" link on it to close it and I would like to close that Ad so that I can avoid making the thread sleep for 20 seconds until the ad goes away on its own.</p>
  
  <p>This is the site: <a href="http://searchsqlserver.com" rel="nofollow">http://searchsqlserver.com</a></p>
  
  <p>I can't seem to access the link using normal findElement techniques and I have been trying with the JavascriptExecutor with no luck.</p>
  
  <p>This is my code (that doesn't work!) to show what I am looking to do:</p>
  
  <pre><code>if (Common.isElementPresent(By.id("adx_al"), driver)){          
  ((JavascriptExecutor)driver).executeScript(findElement(By.linkText("Skip this advertisement")).click());
  
  //Thread.sleep(20000);
  }
  </code></pre>