From 343a07865a20de43d86f289f04355c63965bc7ed Mon Sep 17 00:00:00 2001 From: Andreas Sekulski Date: Wed, 8 Jun 2022 16:07:01 +0200 Subject: [PATCH] Press Key issue with combined keys #67 Sample implementation without example project for analyze purpose. --- atests/Keyboard.robot | 6 +++ atests/Unity.robot | 43 +++++++++++++++++++ atests/util/Common.robot | 2 +- keen.bat | 4 +- .../flaui/util/keyboardinputconverter.py | 4 +- 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 atests/Unity.robot diff --git a/atests/Keyboard.robot b/atests/Keyboard.robot index 832a655..eacbae5 100644 --- a/atests/Keyboard.robot +++ b/atests/Keyboard.robot @@ -46,6 +46,7 @@ ${KEYBOARD_INPUT_SELECTALL} s'CTRL+A' ${KEYBOARD_INPUT_BACKSPACE} s'BACK' ${KEYBOARD_INPUT_COPY} s'CTRL+C' ${KEYBOARD_INPUT_PASTE} s'CTRL+V' +@{KEYBOARD_TRIPLE_OUTPUT} s'SHIFT+ALT+BACK' @{KEYBOARD_INPUT_PASTE_ARRAY} s'CTRL+V' @{KEYBOARD_INPUT_TEXT_SHORTCUT} t'${EXP_VALUE_INPUT_TEXT}' s'CTRL+A' s'CTRL+C' s'END' s'CTRL+V' @@ -131,6 +132,11 @@ False Argument Type ${ERR_MSG} Run Keyword and Expect Error * Press Key ${KEYBOARD_INPUT_TEXT_ARRAY} ${XPATH_INPUT_FIELD} Should Be Equal As Strings ${EXP_ERR_MSG} ${ERR_MSG} +Keyboard Tripple Output + Press Keys ${KEYBOARD_TRIPLE_OUTPUT} ${XPATH_INPUT_FIELD} + Sleep 50s + + *** Keywords *** Reset Textbox Click ${XPATH_RESET} diff --git a/atests/Unity.robot b/atests/Unity.robot new file mode 100644 index 0000000..2796d2d --- /dev/null +++ b/atests/Unity.robot @@ -0,0 +1,43 @@ +*** Settings *** +Documentation Test suite for unity keyword handling. +... + +Library FlaUILibrary uia=${UIA} screenshot_on_failure=False +Library Process +Library StringFormat + +Test Setup Init Test +Test Teardown Stop Application ${PID} + +Resource util/Common.robot +Resource util/XPath.robot + +*** Variables *** +${IMAGE_DIR} ${CURDIR}\\apps\\Ocr +${MAIN_WINDOW_UNITY} /Window[@Name='Keypress'] +${TEST_APP_UNITY} apps\\Unity\\Keypress.exe + +*** Keywords *** +Init Test + ${PID} Start Application ${TEST_APP_UNITY} ${MAIN_WINDOW_UNITY} + Set Global Variable ${PID} ${PID} + Sleep 10s + +*** Test Cases *** +Simple Keyboard Press Key Test + FlaUILibrary.Press Key s'Y' ${MAIN_WINDOW_UNITY} + Sleep 10s + FlaUILibrary.Press Key s'W' ${MAIN_WINDOW_UNITY} + Sleep 10s + +Complex Keyboard Press Key Test + FlaUILibrary.Press Key s'SHIFT+ALT+BACK' ${MAIN_WINDOW_UNITY} + Sleep 10s + + #FlaUILibrary.Press Key s'SHIFT+ALT+EQUALS' + #Sleep 10s + #FlaUILibrary.Press Key s'SHIFT+ALT+ADD' + #Sleep 10s + #FlaUILibrary.Press Key s'SHIFT+ALT+SUBTRACT' + #Sleep 10s + diff --git a/atests/util/Common.robot b/atests/util/Common.robot index c422b9f..27946aa 100644 --- a/atests/util/Common.robot +++ b/atests/util/Common.robot @@ -11,7 +11,7 @@ Init Main Application Stop Application [Arguments] ${pid}=${INTERNAL_PID} ${xpath}=${MAIN_WINDOW} - Close Application ${pid} + FlaUILibrary.Close Application ${pid} Wait Until Element Is Hidden ${xpath} Start Application diff --git a/keen.bat b/keen.bat index f77b9d6..0f05395 100644 --- a/keen.bat +++ b/keen.bat @@ -28,13 +28,13 @@ EXIT /B %ERRORLEVEL% :test_uia2 call cd atests - call robot --name "UIA2" --variable UIA:UIA2 --outputdir ../result/uia2 . + call robot --name "UIA2" --variable UIA:UIA2 --outputdir ../result/uia2 Keyboard.robot call cd .. EXIT /B %ERRORLEVEL% :test_uia3 call cd atests - call robot --name "UIA3" --variable UIA:UIA3 --outputdir ../result/uia3 . + call robot --name "UIA3" --variable UIA:UIA3 --outputdir ../result/uia3 Unity.robot call cd .. EXIT /B %ERRORLEVEL% diff --git a/src/FlaUILibrary/flaui/util/keyboardinputconverter.py b/src/FlaUILibrary/flaui/util/keyboardinputconverter.py index 3eb6154..8e20fc9 100644 --- a/src/FlaUILibrary/flaui/util/keyboardinputconverter.py +++ b/src/FlaUILibrary/flaui/util/keyboardinputconverter.py @@ -3,6 +3,7 @@ from typing import Any from FlaUI.Core.WindowsAPI import VirtualKeyShort # pylint: disable=import-error from FlaUILibrary.flaui.exception import FlaUiError +from FlaUILibrary.robotframework.robotlog import logger class KeyboardInputConverter: @@ -136,9 +137,10 @@ def convert_key_combination(key_combination: Any): (is_success, result) = KeyboardInputConverter._try_convert_to_shortcut(key_combination) if is_success: + logger.info(result) return KeyboardInputConverter.InputType.SHORTCUT, result - return KeyboardInputConverter.InputType.TEXT, result + raise FlaUiError.raise_fla_ui_error("Invalid shortcut usage") if match(KeyboardInputConverter.TEXT, key_combination): return (KeyboardInputConverter.InputType.TEXT,