summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-08 14:54:01 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-08 14:54:01 +0100
commitc1fa0f8b86cfdc7d779f815f71069f3e842b0ce9 (patch)
treeb424f31890821a9a445a516195aca92ebb821b15 /tests
parentdeb2495f89697519e0468b29b94351d3ba99055b (diff)
downloadnextcloud-server-c1fa0f8b86cfdc7d779f815f71069f3e842b0ce9.tar.gz
nextcloud-server-c1fa0f8b86cfdc7d779f815f71069f3e842b0ce9.zip
Add automatic handling of NoSuchElement exceptions
NoSuchElement exceptions are sometimes thrown instead of StaleElementReference exceptions. This can happen when the Selenium2 driver for Mink performs an action on an element through the WebDriver session instead of directly through the WebDriver element. In that case, if the element with the given ID does not exist, a NoSuchElement exception would be thrown instead of a StaleElementReference exception, so those cases are handled like StaleElementReference exceptions. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/core/ElementWrapper.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/acceptance/features/core/ElementWrapper.php b/tests/acceptance/features/core/ElementWrapper.php
index c46ee140340..6f814921125 100644
--- a/tests/acceptance/features/core/ElementWrapper.php
+++ b/tests/acceptance/features/core/ElementWrapper.php
@@ -38,6 +38,14 @@
* the element is stale it is found again using the same parameters to find it
* in the first place.
*
+ * NoSuchElement exceptions are sometimes thrown instead of
+ * StaleElementReference exceptions. This can happen when the Selenium2 driver
+ * for Mink performs an action on an element through the WebDriver session
+ * instead of directly through the WebDriver element. In that case, if the
+ * element with the given ID does not exist, a NoSuchElement exception would be
+ * thrown instead of a StaleElementReference exception, so those cases are
+ * handled like StaleElementReference exceptions.
+ *
* ElementNotVisible exceptions are thrown when the command requires the element
* to be visible but the element is not. Finding an element only guarantees that
* (at that time) the element is attached to the DOM, but it does not provide
@@ -200,8 +208,8 @@ class ElementWrapper {
/**
* Executes the given command.
*
- * If a StaleElementReference exception is thrown the wrapped element is
- * found again and, then, the command is executed again.
+ * If a StaleElementReference or a NoSuchElement exception is thrown the
+ * wrapped element is found again and, then, the command is executed again.
*
* @param \Closure $commandCallback the command to execute.
* @param string $errorMessage an error message that describes the failed
@@ -216,6 +224,8 @@ class ElementWrapper {
return $commandCallback();
} catch (\WebDriver\Exception\StaleElementReference $exception) {
$this->printFailedCommandMessage($exception, $errorMessage);
+ } catch (\WebDriver\Exception\NoSuchElement $exception) {
+ $this->printFailedCommandMessage($exception, $errorMessage);
}
$this->element = $this->elementFinder->find();
@@ -226,10 +236,10 @@ class ElementWrapper {
/**
* Executes the given command on a visible element.
*
- * If a StaleElementReference exception is thrown the wrapped element is
- * found again and, then, the command is executed again. If an
- * ElementNotVisible or a MoveTargetOutOfBounds exception is thrown it is
- * waited for the wrapped element to be visible and, then, the command is
+ * If a StaleElementReference or a NoSuchElement exception is thrown the
+ * wrapped element is found again and, then, the command is executed again.
+ * 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.
*
* @param \Closure $commandCallback the command to execute.