From bcd3cba3f44c205779eaaccfe65dbf622e20b927 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Fri, 7 Sep 2018 14:22:14 +0545 Subject: [PATCH] move getPageTitle() to pageObject --- .../features/bootstrap/WebUIGeneralContext.php | 5 +---- tests/acceptance/features/lib/OwncloudPage.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/WebUIGeneralContext.php b/tests/acceptance/features/bootstrap/WebUIGeneralContext.php index 79727fe52dbf..7f603d58e229 100644 --- a/tests/acceptance/features/bootstrap/WebUIGeneralContext.php +++ b/tests/acceptance/features/bootstrap/WebUIGeneralContext.php @@ -364,10 +364,7 @@ public function dialogsShouldBeDisplayedOnTheWebUI( */ public function theUserShouldBeRedirectedToAWebUIPageWithTheTitle($title) { $this->owncloudPage->waitForOutstandingAjaxCalls($this->getSession()); - $actualTitle = $this->getSession()->getPage()->find( - 'xpath', './/title' - )->getHtml(); - PHPUnit_Framework_Assert::assertEquals($title, \trim($actualTitle)); + PHPUnit_Framework_Assert::assertEquals($title, $this->owncloudPage->getPageTitle()); } /** diff --git a/tests/acceptance/features/lib/OwncloudPage.php b/tests/acceptance/features/lib/OwncloudPage.php index e5d4a7e3d260..440634c19936 100644 --- a/tests/acceptance/features/lib/OwncloudPage.php +++ b/tests/acceptance/features/lib/OwncloudPage.php @@ -39,6 +39,7 @@ class OwncloudPage extends Page { protected $notificationId = "notification"; protected $ocDialogXpath = ".//*[@class='oc-dialog']"; protected $avatarImgXpath = ".//div[@id='settings']//div[contains(@class, 'avatardiv')]/img"; + protected $titleXpath = ".//title"; /** * used to store the unchanged path string when $path gets changed @@ -181,6 +182,21 @@ public function getNotifications() { return $notificationsText; } + /** + * + * @throws ElementNotFoundException + * @return string + */ + public function getPageTitle() { + $title = $this->find('xpath', $this->titleXpath); + if ($title === null) { + throw new ElementNotFoundException( + __METHOD__ . " could not find title element" + ); + } + return \trim($title->getHtml()); + } + /** * Get all open oc dialogs *