AjaxFormImageButtonTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Drupal\FunctionalJavascriptTests\Ajax;
  3. use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
  4. /**
  5. * Tests the Ajax image buttons work with key press events.
  6. *
  7. * @group Ajax
  8. */
  9. class AjaxFormImageButtonTest extends WebDriverTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static $modules = ['ajax_forms_test'];
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected $defaultTheme = 'stark';
  18. /**
  19. * Tests image buttons can be operated with the keyboard ENTER key.
  20. */
  21. public function testAjaxImageButtonKeypressEnter() {
  22. // Get a Field UI manage-display page.
  23. $this->drupalGet('ajax_forms_image_button_form');
  24. $assertSession = $this->assertSession();
  25. $session = $this->getSession();
  26. $button = $session->getPage()->findButton('Edit');
  27. $button->keyPress(13);
  28. $this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed');
  29. }
  30. /**
  31. * Tests image buttons can be operated with the keyboard SPACE key.
  32. */
  33. public function testAjaxImageButtonKeypressSpace() {
  34. // Get a Field UI manage-display page.
  35. $this->drupalGet('ajax_forms_image_button_form');
  36. $assertSession = $this->assertSession();
  37. $session = $this->getSession();
  38. $button = $session->getPage()->findButton('Edit');
  39. $button->keyPress(32);
  40. $this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed');
  41. }
  42. }