From 2aa4fb0bdc5d4839fb9cfd6214abd5f726fcf456 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Wed, 21 Jun 2017 07:30:14 +0545 Subject: [PATCH 1/3] make sure the input field is cleaned before setting the file name --- tests/ui/features/lib/FilesPage.php | 2 +- tests/ui/features/lib/OwncloudPage.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/ui/features/lib/FilesPage.php b/tests/ui/features/lib/FilesPage.php index 5d36bd699c78..ee4b655eb3c2 100644 --- a/tests/ui/features/lib/FilesPage.php +++ b/tests/ui/features/lib/FilesPage.php @@ -280,7 +280,7 @@ private function _renameFile($fromFileName, $toFileName, Session $session) if ($inputField === null) { throw new ElementNotFoundException("could not find input field"); } - $inputField->setValue($toFileName); + $this->cleanInputAndSetValue($inputField, $toFileName); $inputField->blur(); $this->waitTillElementIsNull($this->fileBusyIndicatorXpath); } diff --git a/tests/ui/features/lib/OwncloudPage.php b/tests/ui/features/lib/OwncloudPage.php index 0c1587b95bfc..35bec1f96fc8 100644 --- a/tests/ui/features/lib/OwncloudPage.php +++ b/tests/ui/features/lib/OwncloudPage.php @@ -27,6 +27,7 @@ use Behat\Mink\Session; use Behat\Mink\Element\NodeElement; use WebDriver\Exception as WebDriverException; +use WebDriver\Key; class OwncloudPage extends Page { @@ -245,4 +246,27 @@ protected function elementHasCSSValue($element, $property, $value) return $exists; } + + /** + * sends an END key and then BACKSPACEs to delete the current value + * then sends the new value + * checks the set value and sends the Escape key + throws an exception + * if the value is not set corectly + * + * @param NodeElement $inputField + * @param string $value + * @throws \Exception + */ + protected function cleanInputAndSetValue(NodeElement $inputField, $value) { + $resultValue = $inputField->getValue(); + $existingValueLength = strlen($resultValue); + $deleteSequence = Key::END . str_repeat(Key::BACKSPACE, $existingValueLength); + $inputField->setValue($deleteSequence); + $inputField->setValue($value); + $resultValue = $inputField->getValue(); + if ($resultValue !== $value) { + $inputField->keyUp(27); //send escape + throw new \Exception("value of input field is not what we expect"); + } + } } \ No newline at end of file From 4026a3b5d3452169517624f31c099684b5c98acc Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Wed, 21 Jun 2017 07:30:28 +0545 Subject: [PATCH 2/3] more slack assertion for amout of displayed notifications --- tests/ui/features/bootstrap/FeatureContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/features/bootstrap/FeatureContext.php b/tests/ui/features/bootstrap/FeatureContext.php index f7f8fff6a002..5c190d32ce34 100644 --- a/tests/ui/features/bootstrap/FeatureContext.php +++ b/tests/ui/features/bootstrap/FeatureContext.php @@ -62,7 +62,7 @@ public function notificationsShouldBeDisplayedWithTheText(TableNode $table) { $notifications = $this->owncloudPage->getNotifications(); $tableRows=$table->getRows(); - PHPUnit_Framework_Assert::assertEquals( + PHPUnit_Framework_Assert::assertGreaterThanOrEqual( count($tableRows), count($notifications) ); From ba2e35af567ce2d04103fb4499be07822ecca771 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Wed, 21 Jun 2017 09:04:52 +0545 Subject: [PATCH 3/3] typos --- tests/ui/features/lib/OwncloudPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/features/lib/OwncloudPage.php b/tests/ui/features/lib/OwncloudPage.php index 35bec1f96fc8..97d9230d3a3e 100644 --- a/tests/ui/features/lib/OwncloudPage.php +++ b/tests/ui/features/lib/OwncloudPage.php @@ -251,7 +251,7 @@ protected function elementHasCSSValue($element, $property, $value) * sends an END key and then BACKSPACEs to delete the current value * then sends the new value * checks the set value and sends the Escape key + throws an exception - * if the value is not set corectly + * if the value is not set correctly * * @param NodeElement $inputField * @param string $value