summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 02be0937675..4951dc43f1d 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -452,7 +452,16 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @Given I write down the shared link
*/
public function iWriteDownTheSharedLink() {
- $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::shareLinkField(), 10)->getValue();
+ // The shared link field always exists in the DOM (once the "Sharing"
+ // tab is loaded), but its value is the actual shared link only when it
+ // is visible.
+ if (!$this->waitForElementToBeEventuallyShown(
+ self::shareLinkField(),
+ $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
+ PHPUnit_Framework_Assert::fail("The shared link was not shown yet after $timeout seconds");
+ }
+
+ $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::shareLinkField())->getValue();
}
/**
@@ -641,6 +650,20 @@ class FilesAppContext implements Context, ActorAwareInterface {
$this->iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown();
}
+ private function waitForElementToBeEventuallyShown($elementLocator, $timeout = 10, $timeoutStep = 1) {
+ $actor = $this->actor;
+
+ $elementShownCallback = function() use ($actor, $elementLocator) {
+ try {
+ return $actor->find($elementLocator)->isVisible();
+ } catch (NoSuchElementException $exception) {
+ return false;
+ }
+ };
+
+ return Utils::waitFor($elementShownCallback, $timeout, $timeoutStep);
+ }
+
private function waitForElementToBeEventuallyNotShown($elementLocator, $timeout = 10, $timeoutStep = 1) {
$actor = $this->actor;