From 264421b5da86bf8c721c95e1f375a1d75b812140 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 14 Oct 2018 20:56:50 +0200 Subject: [PATCH] Move the browser window of an actor to the foreground when acting as him MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Each time a new actor appears in a scenario the browser window of the new actor is put in front of the browser windows of the previous actors. Before, when acting again as a previous actor his browser window stayed in the background; in most cases everything worked fine even if the window was in the background, but due to a bug in the Firefox driver of Selenium and/or maybe in Firefox itself when the window was in the background it was not possible to set the value of an input field that had a range selected. Now, when acting again as a previous actor his browser window is brought to the foreground. This prevents the bug from manifesting, but also reflects better how a user would interact with the browser in real life. Signed-off-by: Daniel Calviño Sánchez --- tests/acceptance/features/bootstrap/FileListContext.php | 9 +++++++++ tests/acceptance/features/core/ActorContext.php | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php index 6a39d7a999f..5206e6417de 100644 --- a/tests/acceptance/features/bootstrap/FileListContext.php +++ b/tests/acceptance/features/bootstrap/FileListContext.php @@ -295,6 +295,15 @@ class FileListContext implements Context, ActorAwareInterface { $this->actor->find(self::renameMenuItem(), 2)->click(); + // For reference, due to a bug in the Firefox driver of Selenium and/or + // maybe in Firefox itself, as a range is selected in the rename input + // (the name of the file, without its extension) when the value is set + // the window must be in the foreground. Otherwise, if the window is in + // the background, instead of setting the value in the whole field it + // would be set only in the selected range. + // 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"); } diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php index 2cdc4b01ff1..81587e40682 100644 --- a/tests/acceptance/features/core/ActorContext.php +++ b/tests/acceptance/features/core/ActorContext.php @@ -164,6 +164,14 @@ class ActorContext extends RawMinkContext { } $this->currentActor = $this->actors[$actorName]; + + // Ensure that the browser window of the actor is the one in the + // foreground; this works around a bug in the Firefox driver of Selenium + // and/or maybe in Firefox itself when interacting with a window in the + // background, but also reflects better how the user would interact with + // the browser in real life. + $session = $this->actors[$actorName]->getSession(); + $session->switchToWindow($session->getWindowName()); } /** -- 2.39.5