title: Having trouble getting phpunit-selenium2 to click a button
body: <p>Here is the html for the button:</p>
  
  <pre><code>&lt;button class="btn btn-hover-success"&gt;&lt;i class="icon-plus"&gt;&lt;/i&gt; Add&lt;/button&gt;
  </code></pre>
  
  <p>Here is the XPath path according to the chrome extension:</p>
  
  <pre><code>/body[@class='wide']/div[@class='container']/div[@id='main']/div[@class='container']/div[@class='content']/div[@class='users form']/form[@id='UserAddForm']/div[@class='button-control-row']/button[@class='btn btn-hover-success']
  </code></pre>
  
  <p>I have tried to target the button using <code>byXPath</code> and <code>byCssSelector</code> (and <code>byLinkText</code>, but it's not actually a link) without success.  This is the closest I have come:</p>
  
  <pre><code>    // Attempt to add a bogus user
      $netidInput = $this-&gt;byId('UserNetid');
      $netidInput-&gt;value('bogus01');
      $submitLink = $this-&gt;byCssSelector('button');
      $this-&gt;assertEquals('Add', $submitLink-&gt;text());
      $this-&gt;click();
      $this-&gt;assertContains('Users', $this-&gt;title());
  </code></pre>
  
  <p>The <code>assertEquals</code> successfully matches the 'Add' which is the button text but it can't click it.  I get the following error:</p>
  
  <pre>
  [root@#### View]# phpunit UsersViewTest.php 
  PHPUnit 3.7.18 by Sebastian Bergmann.
  
  E
  
  Time: 5 seconds, Memory: 5.75Mb
  
  There was 1 error:
  
  1) UsersViewTest::testMyTest
  PHPUnit_Extensions_Selenium2TestCase_WebDriverException: '[JavaScript Error: "can't access dead object" {file: "file:///tmp/anonymous8204548738502860021webdriver-profile/extensions/fxdriver@googlecode.com/components/synthetic-mouse.js" line: 7462}]' when calling method: [wdIMouse::click]
  Build info: version: '2.43.0', revision: '597b76b', time: '2014-09-09 20:52:14'
  System info: host: '####', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.el6.x86_64', java.version: '1.6.0_24'
  Driver info: driver.version: unknown
  
  /var/www/html/formsdev/app/Plugin/BaseApp/Test/Case/View/UsersViewTest.php:25
  /var/www/html/formsdev/app/Plugin/BaseApp/Test/Case/View/UsersViewTest.php:25
  
  FAILURES!
  Tests: 1, Assertions: 2, Errors: 1.
  </pre>
  
  <p>This is running against the Xvfb headless browser on RHEL 6.4.  Please let me know if I left out any relevant information.  Thanks for any suggestions you may have to offer!</p>
  
  <p>Edit: adding another attempt with a different error that may trigger something for someone.</p>
  
  <pre><code>    $submitLink = $this-&gt;byXPath("//button[contains(text(),'Add')]");
      $this-&gt;assertEquals('Add', $submitLink-&gt;text());
      $this-&gt;click("//button[contains(text(),'Add')]");
  </code></pre>
  
  <p>This results in the error:</p>
  
  <p><code>There was 1 error:
  1) UsersViewTest::testMyTest
  PHPUnit_Extensions_Selenium2TestCase_WebDriverException: java.lang.String cannot be cast to java.lang.Long
  </code></p>