From b13e13537f4180d9ff12bc0aac8215483c694736 Mon Sep 17 00:00:00 2001 From: Nick Abalov Date: Fri, 16 Sep 2016 16:40:31 +0700 Subject: [PATCH 1/2] Add clear element command support --- .../py-functional/tests/test_commands.py | 33 ++++++++++++- .../TestApp.WindowsPhone/MainPage.xaml | 1 + .../Winium.StoreApps.InnerServer/Automator.cs | 4 ++ .../Commands/ClearCommand.cs | 41 +++++++++++++++++ .../Commands/Helpers/ControlExtensions.cs | 46 +++++++++++++++++++ .../Commands/ValueCommand.cs | 35 +------------- .../Winium.StoreApps.InnerServer.csproj | 2 + 7 files changed, 126 insertions(+), 36 deletions(-) create mode 100644 Winium/Winium.StoreApps.InnerServer/Commands/ClearCommand.cs create mode 100644 Winium/Winium.StoreApps.InnerServer/Commands/Helpers/ControlExtensions.cs diff --git a/Winium/TestApp.Test/py-functional/tests/test_commands.py b/Winium/TestApp.Test/py-functional/tests/test_commands.py index 0e64fde..29db654 100644 --- a/Winium/TestApp.Test/py-functional/tests/test_commands.py +++ b/Winium/TestApp.Test/py-functional/tests/test_commands.py @@ -272,7 +272,7 @@ def test_attribute_set(self, attribute, value): assert str(value) == element.get_attribute(attribute) -class TestBasicInput(WuaTestCase): +class TestBasicInput(UsesSecondTab): __shared_session__ = False def test_send_keys_to_element(self): @@ -285,6 +285,34 @@ def test_send_keys_to_element(self): element.send_keys(actual_input) assert actual_input.replace(Keys.ENTER, '\r\n') == element.text + def test_send_keys_to_number_input(self, second_tab): + """ + POST /session/:sessionId/element/:id/value Send a sequence of key strokes to an element. + TODO: test magic keys + """ + actual_input = '123' + element = second_tab.find_element_by_id('NumericInput') + element.send_keys(actual_input) + assert actual_input == element.text + + def test_clear_number_input(self, second_tab): + """ + POST /session/:sessionId/element/:id/value Send a sequence of key strokes to an element. + TODO: test magic keys + """ + actual_input = '123' + element = second_tab.find_element_by_id('NumericInput') + element.send_keys(actual_input) + element.clear() + assert '' == element.text + + def test_clear_element(self): + actual_input = 'Some test string' + Keys.ENTER + element = self.driver.find_element_by_id('MyTextBox') + element.send_keys(actual_input) + element.clear() + assert '' == element.text + def test_send_keys_to_active_element(self): element = self.driver.find_element_by_id('MyTextBox') element.click() @@ -308,7 +336,8 @@ def test_back(self): def test_click_element(self): element = self.driver.find_element_by_id('SetButton') element.click() - assert 'CARAMBA' == self.driver.find_element_by_id('MyTextBox').text + actual_value = self.driver.find_element_by_id('MyTextBox').text + assert 'CARAMBA' == actual_value @pytest.mark.skipif(True, reason="TODO") diff --git a/Winium/TestApp/TestApp.WindowsPhone/MainPage.xaml b/Winium/TestApp/TestApp.WindowsPhone/MainPage.xaml index 760a052..93d93eb 100644 --- a/Winium/TestApp/TestApp.WindowsPhone/MainPage.xaml +++ b/Winium/TestApp/TestApp.WindowsPhone/MainPage.xaml @@ -52,6 +52,7 @@