@@ -346,7 +346,16 @@ public function iShareTheLinkFor($fileName) {
346346 * @Given I write down the shared link
347347 */
348348 public function iWriteDownTheSharedLink () {
349- $ this ->actor ->getSharedNotebook ()["shared link " ] = $ this ->actor ->find (self ::shareLinkField (), 10 )->getValue ();
349+ // The shared link field always exists in the DOM (once the "Sharing"
350+ // tab is loaded), but its value is the actual shared link only when it
351+ // is visible.
352+ if (!$ this ->waitForElementToBeEventuallyShown (
353+ self ::shareLinkField (),
354+ $ timeout = 10 * $ this ->actor ->getFindTimeoutMultiplier ())) {
355+ PHPUnit_Framework_Assert::fail ("The shared link was not shown yet after $ timeout seconds " );
356+ }
357+
358+ $ this ->actor ->getSharedNotebook ()["shared link " ] = $ this ->actor ->find (self ::shareLinkField ())->getValue ();
350359 }
351360
352361 /**
@@ -486,7 +495,9 @@ public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($
486495 * @When I see that the :tabName tab in the details view is eventually loaded
487496 */
488497 public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded ($ tabName ) {
489- if (!$ this ->waitForElementToBeEventuallyNotShown (self ::loadingIconForTabInCurrentSectionDetailsViewNamed ($ tabName ), $ timeout = 10 )) {
498+ if (!$ this ->waitForElementToBeEventuallyNotShown (
499+ self ::loadingIconForTabInCurrentSectionDetailsViewNamed ($ tabName ),
500+ $ timeout = 10 * $ this ->actor ->getFindTimeoutMultiplier ())) {
490501 PHPUnit_Framework_Assert::fail ("The $ tabName tab in the details view has not been loaded after $ timeout seconds " );
491502 }
492503 }
@@ -502,7 +513,9 @@ public function iSeeThatTheWorkingIconForPasswordProtectIsShown() {
502513 * @Then I see that the working icon for password protect is eventually not shown
503514 */
504515 public function iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown () {
505- if (!$ this ->waitForElementToBeEventuallyNotShown (self ::passwordProtectWorkingIcon (), $ timeout = 10 )) {
516+ if (!$ this ->waitForElementToBeEventuallyNotShown (
517+ self ::passwordProtectWorkingIcon (),
518+ $ timeout = 10 * $ this ->actor ->getFindTimeoutMultiplier ())) {
506519 PHPUnit_Framework_Assert::fail ("The working icon for password protect is still shown after $ timeout seconds " );
507520 }
508521 }
@@ -517,17 +530,31 @@ public function iShareTheLinkForProtectedByThePassword($fileName, $password) {
517530 $ this ->iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown ();
518531 }
519532
533+ private function waitForElementToBeEventuallyShown ($ elementLocator , $ timeout = 10 , $ timeoutStep = 1 ) {
534+ $ actor = $ this ->actor ;
535+
536+ $ elementShownCallback = function () use ($ actor , $ elementLocator ) {
537+ try {
538+ return $ actor ->find ($ elementLocator )->isVisible ();
539+ } catch (NoSuchElementException $ exception ) {
540+ return false ;
541+ }
542+ };
543+
544+ return Utils::waitFor ($ elementShownCallback , $ timeout , $ timeoutStep );
545+ }
546+
520547 private function waitForElementToBeEventuallyNotShown ($ elementLocator , $ timeout = 10 , $ timeoutStep = 1 ) {
521548 $ actor = $ this ->actor ;
522549
523- $ elementNotFoundCallback = function () use ($ actor , $ elementLocator ) {
550+ $ elementNotShownCallback = function () use ($ actor , $ elementLocator ) {
524551 try {
525552 return !$ actor ->find ($ elementLocator )->isVisible ();
526553 } catch (NoSuchElementException $ exception ) {
527554 return true ;
528555 }
529556 };
530557
531- return Utils::waitFor ($ elementNotFoundCallback , $ timeout , $ timeoutStep );
558+ return Utils::waitFor ($ elementNotShownCallback , $ timeout , $ timeoutStep );
532559 }
533560}
0 commit comments