title: How to alter a hidden field within a TestCase in Laravel 5?
body: <p>I have the following <em>Test</em> in which I'm needing to <em>alter</em> the value of a hidden input field, before submitting.</p>
  
  <blockquote>
    <p>How can I alter the <em>hidden</em> <code>_token</code> field before submitting?</p>
  </blockquote>
  
  <pre><code>public function it_fails_to_submit_aun_invalid_token_post()
  {
      // Given I am a not authenticated user (guest)
  
      // And I visit the homepage
  
      $this-&gt;visit('/auth/login');
  
      // And I fill the login form
      $this-&gt;type('test@example.org', 'email')
           -&gt;type('password', 'password');
  
      // TODO: HERE Change the _token field value to simulate invalidation/tampering
      // Would be something similar to:
      // $this-&gt;type('INVALID TOKEN', '_token');
      // But this doesn't work because of (apparently) the DOM lib limitations inherited by TestCase
  
      $this-&gt;click('Login');
  
      // Then I should see an invalid token message
      $this-&gt;see('please submit your form again');
  }
  </code></pre>
  
  <p>The full test code on the <a href="https://github.com/alariva/timegrid/blob/development/tests/unit/WelcomeControllerTest.php#L78" rel="nofollow">github project is here</a></p>
  
  <p>There is a <a href="https://laracasts.com/discuss/channels/testing/how-to-this-type-in-a-hidden-input?page=1#reply-120377" rel="nofollow">similar discussion on Laracasts</a> which seem not to solve this problem yet.</p>