From 7625a8741202aa14bc3e98ad02a1adab0d1dd475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 17 Jan 2021 23:30:01 +0100 Subject: [PATCH] Update Selenium driver for Mink from 1.3.1 to 1.4.0 in acceptance tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since version 1.4.0 the Selenium driver for Mink uses again the element on which the value was set (see https://github.com/minkphp/MinkSelenium2Driver/pull/286). When creating a new folder or renaming one sending a new line ("\r") caused the element on which the value was set to be removed, so the element was no longer attached to the DOM when the driver tried to use it again, and thus a "StaleElementReference" exception was thrown. Due to this now it is needed to explicitly click the confirm button when creating a new folder. In the case of the renaming, on the other hand, nothing else besides not sending the new line is needed, as the Selenium driver now unfocuses the element (that is why it uses again the element after setting the value) which triggers the renaming. Besides that, the Selenium driver for Mink uses a library to simulate certain events, bitovi/syn. In version 1.4.0 that library was updated to version 0.0.3, which seems to somehow break pressing the "escape" key. Due to this now the sharing menu has to be closed by pressing "enter" on the share menu button instead. Signed-off-by: Daniel Calviño Sánchez --- tests/acceptance/composer.json | 2 +- tests/acceptance/composer.lock | 28 +++++++++---------- .../features/bootstrap/FileListContext.php | 16 +++++++++-- .../bootstrap/FilesAppSharingContext.php | 4 +-- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tests/acceptance/composer.json b/tests/acceptance/composer.json index 27a30f8fb8..64808d9e28 100644 --- a/tests/acceptance/composer.json +++ b/tests/acceptance/composer.json @@ -3,7 +3,7 @@ "behat/behat": "3.8.1", "behat/mink": "1.7.1", "behat/mink-extension": "2.3.1", - "behat/mink-selenium2-driver": "1.3.1", + "behat/mink-selenium2-driver": "1.4.0", "phpunit/phpunit": "6.5.14" }, "autoload": { diff --git a/tests/acceptance/composer.lock b/tests/acceptance/composer.lock index 94f599c399..4f18fb9c40 100644 --- a/tests/acceptance/composer.lock +++ b/tests/acceptance/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "f75fc126df5999c922c96e1593eabf31", + "content-hash": "23dccfe6d77917642d1be256dc842b55", "packages": [], "packages-dev": [ { @@ -265,30 +265,30 @@ }, { "name": "behat/mink-selenium2-driver", - "version": "v1.3.1", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/minkphp/MinkSelenium2Driver.git", - "reference": "473a9f3ebe0c134ee1e623ce8a9c852832020288" + "reference": "312a967dd527f28980cce40850339cd5316da092" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/473a9f3ebe0c134ee1e623ce8a9c852832020288", - "reference": "473a9f3ebe0c134ee1e623ce8a9c852832020288", + "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/312a967dd527f28980cce40850339cd5316da092", + "reference": "312a967dd527f28980cce40850339cd5316da092", "shasum": "" }, "require": { "behat/mink": "~1.7@dev", "instaclick/php-webdriver": "~1.1", - "php": ">=5.3.1" + "php": ">=5.4" }, "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "mink/driver-testsuite": "dev-master" }, "type": "mink-driver", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { @@ -301,15 +301,15 @@ "MIT" ], "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, { "name": "Pete Otaqui", "email": "pete@otaqui.com", "homepage": "https://github.com/pete-otaqui" + }, + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" } ], "description": "Selenium2 (WebDriver) driver for Mink framework", @@ -322,7 +322,7 @@ "testing", "webdriver" ], - "time": "2016-03-05T09:10:18+00:00" + "time": "2020-03-11T14:43:21+00:00" }, { "name": "behat/transliterator", diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php index 5f66c0fbbb..ce2bd9971e 100644 --- a/tests/acceptance/features/bootstrap/FileListContext.php +++ b/tests/acceptance/features/bootstrap/FileListContext.php @@ -126,11 +126,20 @@ class FileListContext implements Context, ActorAwareInterface { * @return Locator */ public static function createNewFolderMenuItemNameInput($fileListAncestor) { - return Locator::forThe()->css(".filenameform input")-> + return Locator::forThe()->css(".filenameform input[type=text]")-> descendantOf(self::createNewFolderMenuItem($fileListAncestor))-> describedAs("Name input in create new folder menu item in file list"); } + /** + * @return Locator + */ + public static function createNewFolderMenuItemConfirmButton($fileListAncestor) { + return Locator::forThe()->css(".filenameform input[type=submit]")-> + descendantOf(self::createNewFolderMenuItem($fileListAncestor))-> + describedAs("Confirm button in create new folder menu item in file list"); + } + /** * @return Locator */ @@ -356,7 +365,8 @@ class FileListContext implements Context, ActorAwareInterface { $this->actor->find(self::createMenuButton($this->fileListAncestor), 10)->click(); $this->actor->find(self::createNewFolderMenuItem($this->fileListAncestor), 2)->click(); - $this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName . "\r"); + $this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName); + $this->actor->find(self::createNewFolderMenuItemConfirmButton($this->fileListAncestor), 2)->click(); } /** @@ -410,7 +420,7 @@ class FileListContext implements Context, ActorAwareInterface { // This should not be a problem, though, as the default behaviour is to // bring the browser window to the foreground when switching to a // different actor. - $this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2 . "\r"); + $this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2); } /** diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php index 4540d7ae48..e8515fa112 100644 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php @@ -372,8 +372,8 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { self::shareLinkMenu($shareLinkMenuTriggerElement), $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { // It may not be possible to click on the menu button (due to the - // menu itself covering it), so "Esc" key is pressed instead. - $this->actor->find(self::shareLinkMenu($shareLinkMenuTriggerElement), 2)->getWrappedElement()->keyPress(27); + // menu itself covering it), so "Enter" key is pressed instead. + $this->actor->find(self::shareLinkMenuButton(), 2)->getWrappedElement()->keyPress(13); } $this->actor->find(self::copyLinkButton(), 10)->click();