From e5d1c36e7bc889994350ab5defff7e711a900204 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Fri, 17 Mar 2017 19:46:11 +0545 Subject: [PATCH] better waiting for the filesPage to be loaded during UI tests --- .../ui/features/bootstrap/FeatureContext.php | 1 + tests/ui/features/bootstrap/LoginContext.php | 2 +- tests/ui/features/lib/FilesPage.php | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/ui/features/bootstrap/FeatureContext.php b/tests/ui/features/bootstrap/FeatureContext.php index 745aa2462be4..e742af3adf41 100644 --- a/tests/ui/features/bootstrap/FeatureContext.php +++ b/tests/ui/features/bootstrap/FeatureContext.php @@ -46,6 +46,7 @@ public function setUpScenario() { $this->loginPage->open(); $this->filesPage = $this->loginPage->loginAs("admin", "admin"); + $this->filesPage->waitTillPageIsloaded(10); } /** diff --git a/tests/ui/features/bootstrap/LoginContext.php b/tests/ui/features/bootstrap/LoginContext.php index 1849ea446982..9ed380f6a755 100644 --- a/tests/ui/features/bootstrap/LoginContext.php +++ b/tests/ui/features/bootstrap/LoginContext.php @@ -53,7 +53,7 @@ public function iAmOnLoginPage() public function iLoginWithUsernameAndPassword($username, $password) { $this->filesPage = $this->loginPage->loginAs($username, $password); - $this->loginPage->waitTillPageIsloaded(10); + $this->filesPage->waitTillPageIsloaded(10); } /** diff --git a/tests/ui/features/lib/FilesPage.php b/tests/ui/features/lib/FilesPage.php index bfac3977624f..220827f8cefa 100644 --- a/tests/ui/features/lib/FilesPage.php +++ b/tests/ui/features/lib/FilesPage.php @@ -32,8 +32,28 @@ class FilesPage extends OwnCloudPage * @var string $path */ protected $path = '/index.php/apps/files/'; + + protected $emptyContentXpath = ".//*[@id='emptycontent']"; public function findFileInList($filename) { return $this->findLink($filename); } + + //there is no reliable loading indicator on the files page, so waiting for + //the table or the Emplty Folder message to be shown + public function waitTillPageIsloaded($timeout) + { + for ($counter = 0; $counter <= $timeout; $counter ++) { + + $fileList = $this->findById("fileList"); + + if ($fileList !== null && + ($fileList->has("xpath", "//a") || ! $this->find("xpath", + $this->emptyContentXpath)->hasClass("hidden"))) { + break; + } + + sleep(1); + } + } } \ No newline at end of file