Skip to content

Commit

Permalink
Update Selenium driver for Mink from 1.3.1 to 1.4.0 in acceptance tests
Browse files Browse the repository at this point in the history
Since version 1.4.0 the Selenium driver for Mink uses again the element
on which the value was set (see
minkphp/MinkSelenium2Driver#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 <[email protected]>
  • Loading branch information
danxuliu authored and skjnldsv committed Mar 30, 2021
1 parent 223b36e commit 7625a87
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/acceptance/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
28 changes: 14 additions & 14 deletions tests/acceptance/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions tests/acceptance/features/bootstrap/FileListContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,20 @@ public static function createNewFolderMenuItem($fileListAncestor) {
* @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
*/
Expand Down Expand Up @@ -356,7 +365,8 @@ public function iCreateANewFolderNamed($folderName) {
$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();
}

/**
Expand Down Expand Up @@ -410,7 +420,7 @@ public function iRenameTo($fileName1, $fileName2) {
// 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ public function iWriteDownTheSharedLink() {
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();
Expand Down

0 comments on commit 7625a87

Please sign in to comment.