Skip to content

Commit

Permalink
Have asserts in typing tests give more information when they fail
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jan 14, 2016
1 parent e31d170 commit 4029b29
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions py/test/selenium/webdriver/common/typing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ def testShouldFireKeyPressEvents(self):
keyReporter = self.driver.find_element(by=By.ID, value="keyReporter")
keyReporter.send_keys("a")
result = self.driver.find_element(by=By.ID, value="result")
self.assertTrue("press:" in result.text)
self.assertTrue("press:" in result.text, "Expected: {0} . Result is {1}".format("press:", result.text))

def testShouldFireKeyDownEvents(self):
self._loadPage("javascriptPage")
keyReporter = self.driver.find_element(by=By.ID, value="keyReporter")
keyReporter.send_keys("I")
result = self.driver.find_element(by=By.ID, value="result")
self.assertTrue("down" in result.text)
self.assertTrue("down" in result.text, "Expected: {0} . Result is {1}".format("down", result.text))

def testShouldFireKeyUpEvents(self):
self._loadPage("javascriptPage")
keyReporter = self.driver.find_element(by=By.ID, value="keyReporter")
keyReporter.send_keys("a")
result = self.driver.find_element(by=By.ID, value="result")
self.assertTrue("up:" in result.text)
self.assertTrue("up:" in result.text, "Expected: {0} . Result is {1}".format("up:", result.text))

def testShouldTypeLowerCaseLetters(self):
self._loadPage("javascriptPage")
Expand Down Expand Up @@ -141,20 +141,20 @@ def testShouldReportKeyCodeOfArrowKeysUpDownEvents(self):
result = self.driver.find_element(by=By.ID, value="result")
element = self.driver.find_element(by=By.ID, value="keyReporter")
element.send_keys(Keys.ARROW_DOWN)
self.assertTrue("down: 40" in result.text.strip())
self.assertTrue("up: 40" in result.text.strip())
self.assertTrue("down: 40" in result.text.strip(), "Expected: {0} . Result is {1}".format("down: 40", result.text))
self.assertTrue("up: 40" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 40", result.text))

element.send_keys(Keys.ARROW_UP)
self.assertTrue("down: 38" in result.text.strip())
self.assertTrue("up: 38" in result.text.strip())
self.assertTrue("down: 38" in result.text.strip(), "Expected: {0} . Result is {1}".format("down: 38", result.text))
self.assertTrue("up: 38" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 38", result.text))

element.send_keys(Keys.ARROW_LEFT)
self.assertTrue("down: 37" in result.text.strip())
self.assertTrue("up: 37" in result.text.strip())
self.assertTrue("down: 37" in result.text.strip(), "Expected: {0} . Result is {1}".format("down: 37", result.text))
self.assertTrue("up: 37" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 37", result.text))

element.send_keys(Keys.ARROW_RIGHT)
self.assertTrue("down: 39" in result.text.strip())
self.assertTrue("up: 39" in result.text.strip())
self.assertTrue("down: 39" in result.text.strip(), "Expected: {0} . Result is {1}".format("down: 39", result.text))
self.assertTrue("up: 39" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 39", result.text))

# And leave no rubbish/printable keys in the "keyReporter"
self.assertEqual(element.get_attribute("value"), "")
Expand All @@ -175,7 +175,7 @@ def testNumericShiftKeys(self):
numericShiftsEtc = "~!@#$%^&*()_+{}:i\"<>?|END~"
element.send_keys(numericShiftsEtc)
self.assertEqual(element.get_attribute("value"), numericShiftsEtc)
self.assertTrue(" up: 16" in result.text.strip())
self.assertTrue("up: 16" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 16", result.text))

def testLowerCaseAlphaKeys(self):
self._loadPage("javascriptPage")
Expand All @@ -191,7 +191,7 @@ def testUppercaseAlphaKeys(self):
upperAlphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
element.send_keys(upperAlphas)
self.assertEqual(element.get_attribute("value"), upperAlphas)
self.assertTrue(" up: 16" in result.text.strip())
self.assertTrue("up: 16" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 16", result.text))

def testAllPrintableKeys(self):
self._loadPage("javascriptPage")
Expand All @@ -201,7 +201,7 @@ def testAllPrintableKeys(self):
element.send_keys(allPrintable)

self.assertTrue(element.get_attribute("value"), allPrintable)
self.assertTrue(" up: 16" in result.text.strip())
self.assertTrue("up: 16" in result.text.strip(), "Expected: {0} . Result is {1}".format("up: 16", result.text))

def testArrowKeysAndPageUpAndDown(self):
self._loadPage("javascriptPage")
Expand Down

0 comments on commit 4029b29

Please sign in to comment.