Skip to content

Commit

Permalink
Press Key issue with combined keys #67
Browse files Browse the repository at this point in the history
Sample implementation without example project for analyze purpose.
  • Loading branch information
Andreas Sekulski authored and Nepitwin committed Aug 21, 2022
1 parent 344bbc0 commit 343a078
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
6 changes: 6 additions & 0 deletions atests/Keyboard.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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}
Expand Down
43 changes: 43 additions & 0 deletions atests/Unity.robot
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion atests/util/Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions keen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand Down
4 changes: 3 additions & 1 deletion src/FlaUILibrary/flaui/util/keyboardinputconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 343a078

Please sign in to comment.