public function SimpleRecaptchaJavascriptTest::testFileUploadWidget in Simple Google reCAPTCHA 8
Test reCAPTCHA protected form containing file upload widget.
File
- tests/src/ FunctionalJavascript/ SimpleRecaptchaJavascriptTest.php, line 56 
Class
- SimpleRecaptchaJavascriptTest
- JavaScripts tests for the Simple reCAPTCHA module.
Namespace
Drupal\Tests\simple_recaptcha\FunctionalJavascriptCode
public function testFileUploadWidget() {
  // JS preprocessing is disabled in tests by default,.
  // @see https://www.drupal.org/project/drupal/issues/2467937
  $this
    ->config('system.performance')
    ->set('js.preprocess', TRUE)
    ->save();
  drupal_flush_all_caches();
  // Navigate to custom form.
  $this
    ->drupalGet('/simple_recaptcha_test/form');
  // Fill in required field.
  $assert = $this
    ->assertSession();
  $assert
    ->fieldExists('recaptcha_test_name')
    ->setValue('test name');
  // Initial form submit - triggers reCAPTCHA checkbox.
  $this->page
    ->pressButton('Form submit');
  // Go through the reCAPTCHA iframe magic.
  $this
    ->assignNameToCaptchaIframe();
  $this
    ->getSession()
    ->switchToIFrame('recaptcha-iframe');
  $this
    ->click('.recaptcha-checkbox');
  // Give it a while as reCAPTCHA throbber likes to spin for a while..
  $this
    ->getSession()
    ->wait('2000');
  $this
    ->getSession()
    ->switchToIFrame();
  $this->page
    ->pressButton("simple-recaptcha-submit-button");
  $this
    ->htmlOutput();
  $assert
    ->pageTextContains('Clicked on edit-submit');
}