Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1739,7 +1739,7 @@ trigger:
#
#services:
#- name: selenium
# image: selenium/standalone-firefox:2.53.1-beryllium
# image: selenium/standalone-chrome:3.141.59
# environment:
# # Reduce default log level for Selenium server (INFO) as it is too
# # verbose.
Expand Down Expand Up @@ -1769,7 +1769,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1799,7 +1799,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1829,7 +1829,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1859,7 +1859,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1889,7 +1889,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1919,7 +1919,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1949,7 +1949,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -1979,7 +1979,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down Expand Up @@ -2009,7 +2009,7 @@ steps:

services:
- name: selenium
image: selenium/standalone-firefox:2.53.1-beryllium
image: selenium/standalone-chrome:3.141.59
environment:
# Reduce default log level for Selenium server (INFO) as it is too
# verbose.
Expand Down
24 changes: 24 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,39 @@ default:
default:
selenium2:
wd_host: %selenium.server%
browser: "chrome"
capabilities:
extra_capabilities:
goog:chromeOptions:
args: ["disable-dev-shm-usage"]
w3c: false
John:
selenium2:
wd_host: %selenium.server%
browser: "chrome"
capabilities:
extra_capabilities:
goog:chromeOptions:
args: ["disable-dev-shm-usage"]
w3c: false
Jane:
selenium2:
wd_host: %selenium.server%
browser: "chrome"
capabilities:
extra_capabilities:
goog:chromeOptions:
args: ["disable-dev-shm-usage"]
w3c: false
Jim:
selenium2:
wd_host: %selenium.server%
browser: "chrome"
capabilities:
extra_capabilities:
goog:chromeOptions:
args: ["disable-dev-shm-usage"]
w3c: false
Rubeus:
# Rubeus uses a browser that has CSS grid support.
selenium2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function iOpenTheContactsMenu() {
* @When I search for the user :user
*/
public function iSearchForTheUser($user) {
$this->actor->find(self::contactsMenuSearchInput(), 10)->setValue($user . "\r");
$this->actor->find(self::contactsMenuSearchInput(), 10)->setValue($user);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Behat\Behat\Context\Context;
use PHPUnit\Framework\Assert;
use WebDriver\Key;

class FilesAppSharingContext implements Context, ActorAwareInterface {
use ActorAware;
Expand Down Expand Up @@ -427,7 +428,7 @@ public function iProtectTheSharedLinkWithThePassword($password) {
$shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
$this->actor->find(self::passwordProtectCheckbox($shareLinkMenuTriggerElement), 2)->click();

$this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 2)->setValue($password . "\r");
$this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 2)->setValue($password . Key::ENTER);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this

}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/SearchContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function searchResultLink($number) {
* @When I search for :query
*/
public function iSearchFor($query) {
$this->actor->find(self::searchBoxInput(), 10)->setValue($query . "\r");
$this->actor->find(self::searchBoxInput(), 10)->setValue($query);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function statusMessage() {
* @When I set the :parameterName parameter in the Theming app to :parameterValue
*/
public function iSetTheParameterInTheThemingAppTo($parameterName, $parameterValue) {
$this->actor->find(self::inputFieldFor($parameterName), 10)->setValue($parameterValue . "\r");
$this->actor->find(self::inputFieldFor($parameterName), 10)->setValue($parameterValue);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use Behat\Behat\Context\Context;
use PHPUnit\Framework\Assert;
use WebDriver\Key;

class UsersSettingsContext implements Context, ActorAwareInterface {
use ActorAware;
Expand Down Expand Up @@ -242,7 +243,7 @@ public function iCreateUserWithPassword($user, $password) {
* @When I set the :field for :user to :value
*/
public function iSetTheFieldForUserTo($field, $user, $value) {
$this->actor->find(self::inputForUserInCell($field, $user), 2)->setValue($value . "\r");
$this->actor->find(self::inputForUserInCell($field, $user), 2)->setValue($value . Key::ENTER);
}

/**
Expand Down
25 changes: 24 additions & 1 deletion tests/acceptance/features/core/ElementWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@
* exception instead of an ElementNotVisible exception, so those cases are
* handled like ElementNotVisible exceptions.
*
* ElementNotInteractable exceptions are thrown in Selenium 3 when the command
* needs to interact with an element but that is not possible. This could be a
* transitive situation (for example, due to an animation), so the command is
* executed again after a small timeout.
*
* Despite the automatic handling it is possible for the commands to throw those
* exceptions when they are executed again; this class does not handle cases
* like an element becoming stale several times in a row (uncommon) or an
* element not becoming visible before the timeout expires (which would mean
* that the timeout is too short or that the test has to, indeed, fail). In a
* similar way, MoveTargetOutOfBounds exceptions would be thrown again if
* originally they were thrown because the element was visible but "out of
* reach".
* reach". ElementNotInteractable exceptions would be thrown again if it is not
* possible to interact yet with the element after the wait (which could mean
* that the test has to, indeed, fail, although it could mean too that the
* automatic handling needs to be improved).
*
* If needed, automatically handling failed commands can be disabled calling
* "doNotHandleFailedCommands()"; as it returns the ElementWrapper it can be
Expand Down Expand Up @@ -279,6 +287,13 @@ private function executeCommand(\Closure $commandCallback, $errorMessage) {
* If an ElementNotVisible or a MoveTargetOutOfBounds exception is thrown it
* is waited for the wrapped element to be visible and, then, the command is
* executed again.
* If an ElementNotInteractable exception is thrown it is also waited for
* the wrapped element to be visible. It is very likely that the element was
* visible already, but it is not possible to easily check if the element
* can be interacted with, retrying will be only useful if it was a
* transitive situation that resolves itself with a wait (for example, due
* to an animation) and waiting for the element to be visible will always
* start with a wait.
*
* @param \Closure $commandCallback the command to execute.
* @param string $errorMessage an error message that describes the failed
Expand All @@ -295,6 +310,14 @@ private function executeCommandOnVisibleElement(\Closure $commandCallback, $erro
$this->printFailedCommandMessage($exception, $errorMessage);
} catch (\WebDriver\Exception\MoveTargetOutOfBounds $exception) {
$this->printFailedCommandMessage($exception, $errorMessage);
} catch (\Exception $exception) {
// The "ElementNotInteractable" exception is not available yet in
// the current "instaclick/php-webdriver" version, so it is thrown
// as a generic exception with a specific message.
if (stripos($exception->getMessage(), "element not interactable") === false) {
throw $exception;
}
$this->printFailedCommandMessage($exception, $errorMessage);
}

$this->waitForElementToBeVisible();
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ function prepareSelenium() {
SELENIUM_CONTAINER=selenium-nextcloud-local-test-acceptance

echo "Starting Selenium server"
docker run --detach --name=$SELENIUM_CONTAINER --publish 4444:4444 --publish 5900:5900 $DOCKER_OPTIONS selenium/standalone-firefox-debug:2.53.1-beryllium
docker run --detach --name=$SELENIUM_CONTAINER --publish 4444:4444 --publish 5900:5900 $DOCKER_OPTIONS selenium/standalone-chrome-debug:3.141.59

echo "Waiting for Selenium server to be ready"
if ! $TIMEOUT 10s bash -c "while ! curl 127.0.0.1:4444 >/dev/null 2>&1; do sleep 1; done"; then
echo "Could not start Selenium server; running" \
"\"docker run --rm --publish 4444:4444 --publish 5900:5900 $DOCKER_OPTIONS selenium/standalone-firefox-debug:2.53.1-beryllium\"" \
"\"docker run --rm --publish 4444:4444 --publish 5900:5900 $DOCKER_OPTIONS selenium/standalone-chrome-debug:3.141.59\"" \
"could give you a hint of the problem"

exit 1
Expand Down