public function SimpleRecaptchaWebformJavascriptTest::testContactWebform in Simple Google reCAPTCHA 8
Check if reCAPTCHA validation is added to contact webform.
File
- modules/simple_recaptcha_webform/ tests/ src/ FunctionalJavascript/ SimpleRecaptchaWebformJavascriptTest.php, line 15 
Class
- SimpleRecaptchaWebformJavascriptTest
- JavaScripts tests for the Simple reCAPTCHA webform module.
Namespace
Drupal\Tests\simple_recaptcha_webform\FunctionalJavascriptCode
public function testContactWebform() {
  $this
    ->configureModule();
  $this
    ->drupalGet('webform/simple_recaptcha_v2');
  $assert = $this
    ->assertSession();
  $assert
    ->hiddenFieldExists('simple_recaptcha_type');
  $assert
    ->hiddenFieldValueEquals('simple_recaptcha_type', 'v2');
  // Fill in required fields
  $assert
    ->fieldExists('name')
    ->setValue('test name');
  $assert
    ->fieldExists('email')
    ->setValue('test@example.com');
  $assert
    ->fieldExists('subject')
    ->setValue('subject');
  $assert
    ->fieldExists('message')
    ->setValue('message');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Submit');
  $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
    ->getSession()
    ->getPage()
    ->pressButton('Submit');
  $assert
    ->pageTextContains('Your message has been sent.');
  $this
    ->htmlOutput();
}