diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php index 14a3e71677..a9ee69719b 100644 --- a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php @@ -92,8 +92,8 @@ public function testFragmentLink() { $session->getPage(); // 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 = '1200px';"); + // visible. + $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = window.innerHeight*2 +'px';"); $this->assertSession()->waitForElementVisible('css', $ckeditor_id); // Check that the CKEditor-enabled body field is currently not visible in diff --git a/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php index 1c91fbcaa2..585d2d1d38 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', 100000); + $contextualLinks = $this->assertSession()->waitForElement('css', '.contextual-links'); $link = $contextualLinks->findLink('Translate view'); $this->assertNotNull($link, 'Translate view contextual link added.'); } diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php index bc0f23d038..6b15be9425 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php @@ -51,7 +51,7 @@ public function testBlockConfigAccess() { // permission. $web_assert->fieldNotExists('settings[site_information][site_name]'); $page->pressButton('Save Site branding'); - $web_assert->assertWaitOnAjaxRequest(); + $this->waitForOffCanvasToClose(); $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 a766524abb..cc37d6189c 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php @@ -58,7 +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->waitForOffCanvasToClose(); $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)'); $web_assert->assertWaitOnAjaxRequest(); // Confirm we did not save changes to the configuration. @@ -91,7 +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->waitForOffCanvasToClose(); $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/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php index b852a63fef..0e6b9d6251 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php @@ -67,8 +67,7 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_ $block_id = $block->id(); $this->drupalGet('user'); - $web_assert->waitForElement('css', "$block_selector .contextual-links li a"); - $link = $page->find('css', "$block_selector .contextual-links li a"); + $link = $web_assert->waitForElement('css', "$block_selector .contextual-links li a"); $this->assertEquals('Quick edit', $link->getHtml(), "'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')); @@ -140,7 +139,7 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_ $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->getSession()->getPage()->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)->mouseOver(); $this->assertEditModeDisabled(); $this->assertNotEmpty($web_assert->waitForElement('css', '#drupal-live-announce:contains(Exited edit mode)')); $this->waitForNoElement('.contextual-toolbar-tab button:contains(Editing)'); diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php index 659a194e2e..fd163985e7 100644 --- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php +++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php @@ -27,6 +27,7 @@ public function testToolbarToggling() { ]); $this->drupalLogin($admin_user); + // Set size for horizontal toolbar. $this->getSession()->resizeWindow(1200, 600); $this->drupalGet(''); $this->assertNotEmpty($this->assertSession()->waitForElement('css', 'body.toolbar-horizontal')); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php index 689becedeb..ffdbd98eb9 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php @@ -17,23 +17,28 @@ class AjaxCallbacksTest extends WebDriverTestBase { public static $modules = ['ajax_forms_test']; /** - * Tests if Ajax callback works on date/datetime elements. + * Tests if Ajax callback works on date element. */ public function testDateAjaxCallback() { - $this->drupalGet('ajax_forms_test_ajax_element_form'); - $session = $this->getSession(); - $assert = $this->assertSession(); // 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"]')); + $this->drupalGet('ajax_forms_test_ajax_element_form'); + $this->assertNotEmpty($this->getSession()->getPage()->find('xpath', '//div[@id="ajax_date_value"][text()="No date yet selected"]')); + $this->getSession()->executeScript('jQuery("[data-drupal-selector=edit-date]").val("2016-01-01").trigger("change");'); + $this->assertNotEmpty($this->assertSession()->waitForElement('xpath', '//div[@id="ajax_date_value"]/div[text()="2016-01-01"]')); + } + + /** + * Tests if Ajax callback works on datetime element. + */ + public function testDateTimeAjaxCallback() { // Test Ajax callback when datetime changes. - $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"]')); + $this->drupalGet('ajax_forms_test_ajax_element_form'); + $this->assertNotEmpty($this->getSession()->getPage()->find('xpath', '//div[@id="ajax_datetime_value"][text()="No datetime selected."]')); + $this->getSession()->executeScript('jQuery("[data-drupal-selector=edit-datetime-date]").val("2016-01-01");'); + $this->getSession()->executeScript('jQuery("[data-drupal-selector=edit-datetime-time]").val("12:00:00").trigger("change");'); + $this->assertNotEmpty($this->assertSession()->waitForElement('xpath', '//div[@id="ajax_datetime_value"]/div[text()="2016-01-01 12:00:00"]')); } } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php index 5200213894..97204a65fd 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php @@ -41,53 +41,4 @@ public function setCookie($name, $value = NULL) { $this->getWebDriverSession()->setCookie($cookieArray); } - /** - * {@inheritdoc} - */ - public function dragTo($sourceXpath, $destinationXpath) { - $wdSession = $this->getWebDriverSession(); - - $wdSession->moveto([ - 'element' => $wdSession->element('xpath', $sourceXpath)->getID() - ]); - - $script = <<withSyn()->executeJsOnXpath($sourceXpath, $script); - - $wdSession->buttondown(); - $wdSession->moveto([ - 'element' => $wdSession->element('xpath', $destinationXpath)->getID() - ]); - $wdSession->buttonup(); - - $script = <<withSyn()->executeJsOnXpath($destinationXpath, $script); - break; - } - catch (Exception\StaleElementReference $e) { - $retries++; - } - } - } } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php index c8eb385088..ea98c938cf 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php @@ -28,7 +28,7 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions CURLOPT_FAILONERROR => TRUE, ]; $retries = 0; - while ($retries < 5) { + while ($retries < 10) { try { $customHeaders = [ 'Content-Type: application/json;charset=UTF-8', @@ -98,7 +98,7 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions $result = json_decode($rawResult, TRUE); if (isset($result['status']) && $result['status'] === WebDriverException::STALE_ELEMENT_REFERENCE) { - usleep(rand(100000, 1000000)); + usleep(100000); $retries++; continue; } diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 8d6715e373..065dedccb1 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -4,7 +4,6 @@ use Behat\Mink\Driver\GoutteDriver; use Behat\Mink\Element\Element; -use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Mink; use Behat\Mink\Selector\SelectorsHandler; use Behat\Mink\Session; @@ -19,7 +18,6 @@ use Drupal\Core\Test\TestSetupTrait; use Drupal\Core\Url; use Drupal\Core\Utility\Error; -use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver; use Drupal\FunctionalTests\AssertLegacyTrait; use Drupal\Tests\block\Traits\BlockCreationTrait; use Drupal\Tests\node\Traits\ContentTypeCreationTrait; @@ -781,12 +779,6 @@ protected function drupalLogin(AccountInterface $account) { } $this->drupalGet('user/login'); - if ($this->getSession()->getDriver() instanceof DrupalSelenium2Driver) { - $page = $this->getSession()->getPage(); - $page->waitFor(100, function ($page) { - return $this->getSession()->getPage()->findField('edit-pass') && $this->getSession()->getPage()->findField('edit-name') && $this->getSession()->getPage()->findButton('Log in'); - }); - } $this->submitForm([ 'name' => $account->getUsername(),