Issue #2996404 by andrewmacpherson, Krzysztof Domański: Replace old keypress workaround in AjaxFormImageButtonTest

8.7.x
Nathaniel Catchpole 2019-03-04 17:07:38 +00:00
parent b6a04ed1f8
commit 944b157e5b
1 changed files with 3 additions and 11 deletions

View File

@ -19,22 +19,14 @@ class AjaxFormImageButtonTest extends WebDriverTestBase {
/** /**
* Tests image buttons can be operated with the keyboard ENTER key. * Tests image buttons can be operated with the keyboard ENTER key.
*/ */
public function testAjaxImageButton() { public function testAjaxImageButtonKeypressEnter() {
// Get a Field UI manage-display page. // Get a Field UI manage-display page.
$this->drupalGet('ajax_forms_image_button_form'); $this->drupalGet('ajax_forms_image_button_form');
$assertSession = $this->assertSession(); $assertSession = $this->assertSession();
$session = $this->getSession(); $session = $this->getSession();
$enter_key_event = <<<JS $button = $session->getPage()->findButton('Edit');
jQuery('#edit-image-button') $button->keyPress(13);
.trigger(jQuery.Event('keypress', {
which: 13
}));
JS;
// PhantomJS driver has buggy behavior with key events, we send a JavaScript
// key event instead.
// @todo: use WebDriver event when we remove PhantomJS driver.
$session->executeScript($enter_key_event);
$this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed'); $this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed');
} }