diff options
Diffstat (limited to 'testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py')
-rw-r--r-- | testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py b/testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py new file mode 100644 index 000000000..3fcad45fc --- /dev/null +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py @@ -0,0 +1,72 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from marionette_driver.by import By +from marionette_driver.errors import InvalidElementStateException + +from marionette_harness import MarionetteTestCase + + +class TestClear(MarionetteTestCase): + def testWriteableTextInputShouldClear(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + element = self.marionette.find_element(By.ID, "writableTextInput") + element.clear() + self.assertEqual("", element.get_property("value")) + + def testTextInputShouldNotClearWhenReadOnly(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + element = self.marionette.find_element(By.ID,"readOnlyTextInput") + try: + element.clear() + self.fail("Should not have been able to clear") + except InvalidElementStateException: + pass + + def testWritableTextAreaShouldClear(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + element = self.marionette.find_element(By.ID,"writableTextArea") + element.clear() + self.assertEqual("", element.get_property("value")) + + def testTextAreaShouldNotClearWhenDisabled(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + element = self.marionette.find_element(By.ID,"textAreaNotenabled") + try: + element.clear() + self.fail("Should not have been able to clear") + except InvalidElementStateException: + pass + + def testTextAreaShouldNotClearWhenReadOnly(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + element = self.marionette.find_element(By.ID,"textAreaReadOnly") + try: + element.clear() + self.fail("Should not have been able to clear") + except InvalidElementStateException: + pass + + def testContentEditableAreaShouldClear(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + element = self.marionette.find_element(By.ID,"content-editable") + element.clear() + self.assertEqual("", element.text) + + def testTextInputShouldNotClearWhenDisabled(self): + test_html = self.marionette.absolute_url("test_clearing.html") + self.marionette.navigate(test_html) + try: + element = self.marionette.find_element(By.ID,"textInputnotenabled") + self.assertFalse(element.is_enabled()) + element.clear() + self.fail("Should not have been able to clear") + except InvalidElementStateException: + pass |