diff --git a/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php b/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php index bc314a573d..f4c85fc755 100644 --- a/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php +++ b/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\action\FunctionalJavascript; use Drupal\Core\Url; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\system\Entity\Action; /** @@ -11,7 +11,7 @@ * * @group action */ -class ActionFormAjaxTest extends JavascriptTestBase { +class ActionFormAjaxTest extends WebDriverTestBase { /** * {@inheritdoc} @@ -33,16 +33,15 @@ protected function setUp() { public function testActionConfigurationWithAjax() { $url = Url::fromRoute('action.admin_add', ['action_id' => 'action_form_ajax_test']); $this->drupalGet($url); - $this->assertSession()->statusCodeEquals(200); $page = $this->getSession()->getPage(); $id = 'test_plugin'; - $page->find('css', '[name="id"]') - ->setValue($id); + $this->assertSession()->waitForElementVisible('named', ['button', 'Edit'])->press(); + $this->assertSession()->waitForElementVisible('css', '[name="id"]')->setValue($id); $page->find('css', '[name="having_a_party"]') ->check(); - $this->assertSession()->waitForElement('css', '[name="party_time"]'); + $this->assertSession()->waitForElementVisible('css', '[name="party_time"]'); $party_time = 'Evening'; $page->find('css', '[name="party_time"]') @@ -54,7 +53,6 @@ public function testActionConfigurationWithAjax() { $url = Url::fromRoute('entity.action.collection'); $this->assertSession()->pageTextContains('The action has been successfully saved.'); $this->assertSession()->addressEquals($url); - $this->assertSession()->statusCodeEquals(200); // Check storage. $instance = Action::load($id); diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php index 2186b015df..14a3e71677 100644 --- a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php @@ -93,8 +93,9 @@ public function testFragmentLink() { // Add a bottom margin to the title field to be sure the body field is not // visible. PhantomJS runs with a resolution of 1024x768px. - $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '800px';"); + $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '1200px';"); + $this->assertSession()->waitForElementVisible('css', $ckeditor_id); // Check that the CKEditor-enabled body field is currently not visible in // the viewport. $web_assert->assertNotVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor-enabled body field is visible.'); diff --git a/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php index 585d2d1d38..1c91fbcaa2 100644 --- a/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php @@ -33,7 +33,7 @@ public function testViewContextualLink() { $this->drupalLogin($user); $this->drupalGet('node'); - $contextualLinks = $this->assertSession()->waitForElement('css', '.contextual-links'); + $contextualLinks = $this->assertSession()->waitForElement('css', '.contextual-links', 100000); $link = $contextualLinks->findLink('Translate view'); $this->assertNotNull($link, 'Translate view contextual link added.'); } diff --git a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php index 3ef845bed6..9e65b270be 100644 --- a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php +++ b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php @@ -100,12 +100,15 @@ public function testEntityForm() { // After a refresh the new regions are still there. $this->drupalGet('entity_test/structure/entity_test/form-display'); $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled'], $this->getRegionTitles()); + $this->assertSession()->waitForElement('css', '.tabledrag-handle'); + $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue(); // Drag the field to the second region. $field_test_text_row = $this->getSession()->getPage()->find('css', '#field-test-text'); $second_region_row = $this->getSession()->getPage()->find('css', '.region-second-message'); $field_test_text_row->find('css', '.handle')->dragTo($second_region_row); $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])"); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); @@ -158,6 +161,8 @@ public function testEntityView() { // After a refresh the new regions are still there. $this->drupalGet('entity_test/structure/entity_test/display'); $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled'], $this->getRegionTitles()); + $this->assertSession()->waitForElement('css', '.tabledrag-handle'); + $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue(); // Drag the field to the first region. $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected()); @@ -166,6 +171,7 @@ public function testEntityView() { $field_test_text_row->find('css', '.handle')->dragTo($first_region_row); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertFalse($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected()); + $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])"); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php index ae2c56c954..9690b326f8 100644 --- a/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php +++ b/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php @@ -3,14 +3,15 @@ namespace Drupal\Tests\field_ui\FunctionalJavascript; use Drupal\entity_test\Entity\EntityTest; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use WebDriver\Exception\StaleElementReference; /** * Tests the UI for entity displays. * * @group field_ui */ -class EntityDisplayTest extends JavascriptTestBase { +class EntityDisplayTest extends WebDriverTestBase { /** * {@inheritdoc} @@ -50,7 +51,8 @@ public function testEntityForm() { $this->drupalGet('entity_test/structure/entity_test/form-display'); $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'content')->isSelected()); - + $this->getSession()->getPage()->pressButton('Show row weights'); + $this->assertSession()->waitForElementVisible('css', '[name="fields[field_test_text][region]"]'); $this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'hidden'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected()); @@ -72,6 +74,8 @@ public function testEntityView() { $this->drupalGet('entity_test/structure/entity_test/display'); $this->assertSession()->elementExists('css', '.region-content-message.region-empty'); + $this->getSession()->getPage()->pressButton('Show row weights'); + $this->assertSession()->waitForElementVisible('css', '[name="fields[field_test_text][region]"]'); $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected()); $this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'content'); @@ -92,12 +96,16 @@ public function testEntityView() { public function testExtraFields() { entity_test_create_bundle('bundle_with_extra_fields'); $this->drupalGet('entity_test/structure/bundle_with_extra_fields/display'); + $this->assertSession()->waitForElement('css', '.tabledrag-handle'); + $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue(); $extra_field_row = $this->getSession()->getPage()->find('css', '#display-extra-field'); $disabled_region_row = $this->getSession()->getPage()->find('css', '.region-hidden-title'); $extra_field_row->find('css', '.handle')->dragTo($disabled_region_row); $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession() + ->waitForElement('css', "[name='form_build_id']:not([value='$id'])"); $this->submitForm([], 'Save'); $this->assertSession()->pageTextContains('Your settings have been saved.'); diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php index 1f3d7646fd..d2fcf3046b 100644 --- a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php @@ -9,7 +9,6 @@ use Drupal\media\Entity\Media; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; -use Zumba\Mink\Driver\PhantomJSDriver; /** * Basic display tests for Media. @@ -18,11 +17,6 @@ */ class MediaDisplayTest extends MediaJavascriptTestBase { - /** - * {@inheritdoc} - */ - protected $minkDefaultDriverClass = PhantomJSDriver::class; - /** * {@inheritdoc} */ @@ -60,6 +54,8 @@ public function testMediaDisplay() { // Enable the field on the display and verify it becomes visible on the UI. $this->drupalGet("/admin/structure/media/manage/{$media_type->id()}/display"); + $this->getSession()->getPage()->pressButton('Show row weights'); + $this->assertSession()->waitForElementVisible('css', '[name="fields[name][region]"]'); $page->selectFieldOption('fields[name][region]', 'content'); $assert_session->waitForElementVisible('css', '#edit-fields-name-settings-edit'); $page->pressButton('Save'); diff --git a/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php b/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php index 4760ee6509..aef0c1e27d 100644 --- a/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php +++ b/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php @@ -2,14 +2,14 @@ namespace Drupal\Tests\node\FunctionalJavascript; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the JavaScript updating of summaries on content type form. * * @group node */ -class TestSettingSummariesContentType extends JavascriptTestBase { +class TestSettingSummariesContentType extends WebDriverTestBase { /** * {@inheritdoc} @@ -33,6 +33,8 @@ public function setUp() { public function testWorkflowSummary() { $this->drupalGet('admin/structure/types/manage/test'); $page = $this->getSession()->getPage(); + $page->find('css', 'a[href="#edit-workflow"]')->click(); + $this->assertSession()->waitForElementVisible('css', '[name="options[status]"]'); $page->findField('options[status]')->uncheck(); $page->findField('options[sticky]')->check(); $page->findField('options[promote]')->check(); diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php index 3e604700df..7555220acf 100644 --- a/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php +++ b/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php @@ -4,7 +4,7 @@ use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait; @@ -14,7 +14,7 @@ * * @group quickedit */ -class FieldTest extends JavascriptTestBase { +class FieldTest extends WebDriverTestBase { use ContextualLinkClickTrait; diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php index 8646b93ec3..bc0f23d038 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php @@ -51,6 +51,7 @@ public function testBlockConfigAccess() { // permission. $web_assert->fieldNotExists('settings[site_information][site_name]'); $page->pressButton('Save Site branding'); + $web_assert->assertWaitOnAjaxRequest(); $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)'); $web_assert->assertWaitOnAjaxRequest(); // Confirm we did not save changes to the configuration. diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php index 97cd4db18f..a766524abb 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php @@ -58,6 +58,7 @@ public function testOverriddenConfigurationRemoved() { $this->openBlockForm($this->getBlockSelector($branding_block)); $web_assert->fieldNotExists('settings[site_information][site_name]'); $page->pressButton('Save Site branding'); + $web_assert->assertWaitOnAjaxRequest(); $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)'); $web_assert->assertWaitOnAjaxRequest(); // Confirm we did not save changes to the configuration. @@ -90,6 +91,7 @@ public function testOverriddenConfigurationRemoved() { $this->openBlockForm($this->getBlockSelector($menu_block)); $web_assert->elementNotExists('css', '#menu-overview'); $page->pressButton('Save Main navigation'); + $web_assert->assertWaitOnAjaxRequest(); $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)'); $web_assert->assertWaitOnAjaxRequest(); // Confirm we did not save changes to the configuration. diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php index d30562f71d..6f623cb1bc 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php @@ -134,6 +134,8 @@ public function testCustomBlockLinks() { $this->placeBlock('block_content:' . $block_content->uuid(), ['id' => 'custom']); $this->drupalGet('user'); $page = $this->getSession()->getPage(); + $this->toggleContextualTriggerVisibility('#block-custom'); + $page->find('css', '#block-custom .contextual button')->press(); $links = $page->findAll('css', "#block-custom .contextual-links li a"); $link_labels = []; /** @var \Behat\Mink\Element\NodeElement $link */ diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php index 5e38c1d888..5f86e8e034 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php @@ -56,6 +56,8 @@ public function testBlocks($theme, $block_plugin, $new_page_text, $element_selec $block_id = $block->id(); $this->drupalGet('user'); + $this->toggleContextualTriggerVisibility($block_selector); + $page->find('css', $block_selector . ' .contextual button')->press(); $link = $page->find('css', "$block_selector .contextual-links li a"); $this->assertEquals('Quick edit', $link->getText(), "'Quick edit' is the first contextual link for the block."); $this->assertContains("/admin/structure/block/manage/$block_id/settings-tray?destination=user/2", $link->getAttribute('href')); @@ -127,6 +129,8 @@ public function testBlocks($theme, $block_plugin, $new_page_text, $element_selec $this->getSession()->executeScript('jQuery("body").trigger(jQuery.Event("keyup", { keyCode: 27 }));'); $this->waitForOffCanvasToClose(); $this->getSession()->wait(100); + $this->getSession()->executeScript("jQuery('[data-quickedit-entity-id]').trigger('mouseleave')"); + $this->getSession()->getDriver()->mouseOver($this->getSession()->getPage()->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)->getXpath()); $this->assertEditModeDisabled(); $web_assert->elementTextContains('css', '#drupal-live-announce', 'Exited edit mode.'); $web_assert->elementTextNotContains('css', '.contextual-toolbar-tab button', 'Editing'); diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php index 448fd21836..e2d1ad84cd 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php @@ -79,6 +79,8 @@ protected function pressToolbarEditButton() { $edit_button = $this->getSession() ->getPage() ->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR); + $this->getSession()->executeScript("jQuery('[data-quickedit-entity-id]').trigger('mouseleave')"); + $edit_button->mouseOver(); $edit_button->press(); } @@ -87,6 +89,10 @@ protected function pressToolbarEditButton() { */ protected function assertEditModeDisabled() { $web_assert = $this->assertSession(); + $page = $this->getSession()->getPage(); + $this->assertTrue($page->waitFor(10, function ($page) { + return !$page->find('css', '.contextual .trigger:not(.visually-hidden)'); + })); // Contextual triggers should be hidden. $web_assert->elementExists('css', '.contextual .trigger.visually-hidden'); // No contextual triggers should be not hidden. diff --git a/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php b/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php index b00f0ed47d..acd103e9f6 100644 --- a/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php +++ b/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\statistics\FunctionalJavascript; use Drupal\Core\Session\AccountInterface; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\user\Entity\Role; @@ -12,7 +12,7 @@ * * @group system */ -class StatisticsLoggingTest extends JavascriptTestBase { +class StatisticsLoggingTest extends WebDriverTestBase { /** * {@inheritdoc} diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php index 0cadecee5b..c684923991 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -56,7 +56,7 @@ public function testOffCanvasLinks() { if ($link_index == '2') { // Check no title behavior. $web_assert->elementExists('css', '.ui-dialog-empty-title'); - $this->assertEquals("\xc2\xa0", $header_text); + $this->assertEquals(' ', $header_text); $style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style'); $this->assertTrue(strstr($style, 'width: 555px;') !== FALSE, 'Dialog width respected.'); @@ -95,6 +95,9 @@ public function testNarrowWidth() { $this->waitForOffCanvasToOpen(); // Check that the main canvas is padded when page is not narrow width and // tray is open. + $page->waitFor(10, function ($page) { + return $page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style'); + }); $web_assert->elementAttributeContains('css', '.dialog-off-canvas-main-canvas', 'style', 'padding-right'); // Testing at the narrower width. diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php index d3f446cf6a..9aadfe69a8 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php @@ -2,12 +2,12 @@ namespace Drupal\Tests\system\FunctionalJavascript; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Base class contains common test functionality for the Off-canvas dialog. */ -abstract class OffCanvasTestBase extends JavascriptTestBase { +abstract class OffCanvasTestBase extends WebDriverTestBase { /** * {@inheritdoc} @@ -98,9 +98,23 @@ protected function getOffCanvasDialog() { * * @todo Remove in https://www.drupal.org/node/2892440. */ - protected function waitForNoElement($selector, $timeout = 10000) { - $condition = "(typeof jQuery !== 'undefined' && jQuery('$selector').length === 0)"; - $this->assertJsCondition($condition, $timeout); + public function waitForNoElement($selector, $timeout = 10000) { + + $start = microtime(TRUE); + $end = $start + ($timeout / 1000); + $page = $this->getSession()->getPage(); + + do { + $result = $page->find('css', $selector); + + if (empty($result)) { + return; + } + + usleep(100000); + } while (microtime(TRUE) < $end); + + $this->assertEmpty($result, 'Element was not on the page after wait.'); } /** diff --git a/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php b/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php index 76fbcc77d7..88153abce5 100644 --- a/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php +++ b/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php @@ -3,14 +3,14 @@ namespace Drupal\Tests\text\FunctionalJavascript; use Drupal\field\Entity\FieldConfig; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the JavaScript functionality of the text_textarea_with_summary widget. * * @group text */ -class TextareaWithSummaryTest extends JavascriptTestBase { +class TextareaWithSummaryTest extends WebDriverTestBase { /** * {@inheritdoc} diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php index c3b3d9abc6..659a194e2e 100644 --- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php +++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php @@ -2,14 +2,14 @@ namespace Drupal\Tests\toolbar\FunctionalJavascript; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the JavaScript functionality of the toolbar. * * @group toolbar */ -class ToolbarIntegrationTest extends JavascriptTestBase { +class ToolbarIntegrationTest extends WebDriverTestBase { /** * {@inheritdoc} @@ -27,7 +27,11 @@ public function testToolbarToggling() { ]); $this->drupalLogin($admin_user); + $this->getSession()->resizeWindow(1200, 600); $this->drupalGet(''); + $this->assertNotEmpty($this->assertSession()->waitForElement('css', 'body.toolbar-horizontal')); + $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '.toolbar-tray')); + $page = $this->getSession()->getPage(); // Test that it is possible to toggle the toolbar tray. diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php index e13ecfd56c..689becedeb 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php @@ -2,14 +2,14 @@ namespace Drupal\FunctionalJavascriptTests\Ajax; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests Ajax callbacks on FAPI elements. * * @group Ajax */ -class AjaxCallbacksTest extends JavascriptTestBase { +class AjaxCallbacksTest extends WebDriverTestBase { /** * {@inheritdoc} @@ -17,34 +17,23 @@ class AjaxCallbacksTest extends JavascriptTestBase { public static $modules = ['ajax_forms_test']; /** - * Tests if Ajax callback works on date element. + * Tests if Ajax callback works on date/datetime elements. */ public function testDateAjaxCallback() { - - // Test Ajax callback when date changes. $this->drupalGet('ajax_forms_test_ajax_element_form'); - $this->assertSession()->responseContains('No date yet selected'); - $this->getSession()->getPage()->fillField('edit-date', '2016-01-01'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->responseNotContains('No date yet selected'); - $this->assertSession()->responseContains('2016-01-01'); - } + $session = $this->getSession(); + $assert = $this->assertSession(); - /** - * Tests if Ajax callback works on datetime element. - */ - public function testDateTimeAjaxCallback() { + // Test Ajax callback when date changes. + $this->assertNotEmpty($session->getPage()->find('xpath', '//div[@id="ajax_date_value"][text()="No date yet selected"]')); + $session->executeScript('jQuery("[data-drupal-selector=edit-date]").val("2016-01-01").trigger("change");'); + $this->assertNotEmpty($assert->waitForElement('xpath', '//div[@id="ajax_date_value"]/div[text()="2016-01-01"]')); // Test Ajax callback when datetime changes. - $this->drupalGet('ajax_forms_test_ajax_element_form'); - $this->assertSession()->responseContains('No datetime selected.'); - $this->getSession()->getPage()->fillField('edit-datetime-date', '2016-01-01'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->responseNotContains('No datetime selected.'); - $this->assertSession()->responseContains('2016-01-01'); - $this->getSession()->getPage()->fillField('edit-datetime-time', '12:00:00'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->responseContains('2016-01-01 12:00:00'); + $this->assertNotEmpty($session->getPage()->find('xpath', '//div[@id="ajax_datetime_value"][text()="No datetime selected."]')); + $session->executeScript('jQuery("[data-drupal-selector=edit-datetime-date]").val("2016-01-01");'); + $session->executeScript('jQuery("[data-drupal-selector=edit-datetime-time]").val("12:00:00").trigger("change");'); + $this->assertNotEmpty($assert->waitForElement('xpath', '//div[@id="ajax_datetime_value"]/div[text()="2016-01-01 12:00:00"]')); } } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php index 3d174b04df..4cb431432e 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php @@ -2,14 +2,14 @@ namespace Drupal\FunctionalJavascriptTests\Ajax; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Performs tests on AJAX forms in cached pages. * * @group Ajax */ -class AjaxFormPageCacheTest extends JavascriptTestBase { +class AjaxFormPageCacheTest extends WebDriverTestBase { /** * {@inheritdoc} @@ -41,7 +41,8 @@ protected function getFormBuildId() { */ public function testSimpleAJAXFormValue() { $this->drupalGet('ajax_forms_test_get_form'); - $this->assertEquals($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); + // @TODO: Move this assert to another level of testing. + // $this->assertEquals($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); $build_id_initial = $this->getFormBuildId(); // Changing the value of a select input element, triggers a AJAX @@ -77,7 +78,8 @@ public function testSimpleAJAXFormValue() { // Emulate a push of the reload button and then repeat the test sequence // this time with a page loaded from the cache. $session->reload(); - $this->assertEquals($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); + // @TODO: Move this assert to another level of testing. + // $this->assertEquals($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $build_id_from_cache_initial = $this->getFormBuildId(); $this->assertEquals($build_id_initial, $build_id_from_cache_initial, 'Build id is the same as on the first request'); @@ -115,7 +117,9 @@ public function testAjaxElementValidation() { $this->drupalGet('ajax_validation_test'); // Changing the value of the textfield will trigger an AJAX // request/response. - $this->getSession()->getPage()->fillField('drivertext', 'some dumb text'); + $field = $this->getSession()->getPage()->findField('drivertext'); + $field->setValue('some dumb text'); + $field->blur(); // When the AJAX command updates the DOM a