diff --git a/CHANGES.rst b/CHANGES.rst index 36dab2508..f78553356 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,8 @@ Release Notes ============= +- Added new keyword Input Text Into Prompt [boakley][ekasteel] + 1.7.2 ---------------- - Fixed an error where regular functions were not able to be used as a custom locator diff --git a/src/Selenium2Library/keywords/_formelement.py b/src/Selenium2Library/keywords/_formelement.py index 22065b393..7e67e8f6c 100644 --- a/src/Selenium2Library/keywords/_formelement.py +++ b/src/Selenium2Library/keywords/_formelement.py @@ -197,6 +197,15 @@ def input_text(self, locator, text): self._info("Typing text '%s' into text field '%s'" % (text, locator)) self._input_text_into_text_field(locator, text) + def input_text_into_prompt(self, text): + """Types the given `text` into alert box. """ + alert = None + try: + alert = self._current_browser().switch_to_alert() + alert.send_keys(text) + except WebDriverException: + raise RuntimeError('There were no alerts') + def page_should_contain_textfield(self, locator, message='', loglevel='INFO'): """Verifies text field identified by `locator` is found from current page. diff --git a/test/acceptance/keywords/input_text_into_prompt.robot b/test/acceptance/keywords/input_text_into_prompt.robot new file mode 100644 index 000000000..68078a0ad --- /dev/null +++ b/test/acceptance/keywords/input_text_into_prompt.robot @@ -0,0 +1,13 @@ +*Setting* +Variables variables.py +Resource ../resource.robot +Test Setup Go To Page "javascript/alert_prompt.html" + + +*Test Cases* + +Verify Input Text into Prompt + [Documentation] Typing name into prompt + Click Element css=button + Input Text Into Prompt myname + Get Alert Message diff --git a/test/resources/html/javascript/alert_prompt.html b/test/resources/html/javascript/alert_prompt.html new file mode 100644 index 000000000..74c8218ca --- /dev/null +++ b/test/resources/html/javascript/alert_prompt.html @@ -0,0 +1,23 @@ + + +
+ +Click the button to demonstrate the prompt box.
+ + + + + + + + +