class CalculatorTest(unittest.TestCase): """Test Scenario for Calculator""" setup = Setup() calcsession = None calc = None action = None app = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App" def setUp(self): self.calcsession = self.setup.setUp(self.app) self.calc = Calc(self.calcsession) self.action = Action(self.calcsession) def tearDown(self): self.setup.tearDown() def test_addition(self): """Addition test""" print("Adding Test") self.calc.button("One").click() self.calc.button("Nine").click() self.calc.button("Plus").click() self.calc.button("Three").click() self.calc.button("Equals").click() self.assertEqual(self.calc.get_display_result(), "22") def test_subtraction(self): """Subtraction test""" print("Subtraction Test") self.calc.button("One").click() # first click not performed, no idea why self.calc.button("One").click() self.calc.button("Nine").click() self.calc.button("Minus").click() self.calc.button("Three").click() self.calc.button("Equals").click() self.assertEqual(self.calc.get_display_result(), "16") def test_move_calc(self): """Moving test""" print("Moving Test") self.action.click_and_hold(self.calc.app_hold()).move_by_offset( 50, 50).perform() self.action.click_and_hold(self.calc.app_hold()).move_by_offset( -50, -50).perform() # not working ... self.action.context_click(self.calc.app_hold()).perform() time.sleep(2)
class NotepadTest(unittest.TestCase): """Test Scenario for Notepad""" setup = Setup() notepad_session = None notepad = None action = None app = "c:\\windows\\system32\\notepad.exe" def setUp(self): self.notepad_session = self.setup.setUp(self.app) self.notepad = Note(self.notepad_session) self.action = Action(self.notepad_session) def tearDown(self): self.setup.tearDown() def test_01(self): print("Test Case 01") input_text = "Windriver is awesome?" self.notepad.text_area().send_keys(input_text) text_area = self.notepad.text_area() self.assertEqual(text_area.text, input_text) self.notepad.text_area().send_keys(Keys.ALT, Keys.F4) self.notepad.exit_dialog("Cancel").click() self.notepad.text_area().send_keys(Keys.ALT, Keys.F4) self.notepad.exit_dialog("Don't Save").click() def test_02(self): print("Test Case 02") self.notepad.menu("File").click() time.sleep(3) def test_03(self): print("Test Case 03") self.notepad.window("Minimize").click() time.sleep(3)