robotframework-whitelibrary icon indicating copy to clipboard operation
robotframework-whitelibrary copied to clipboard

`Input text to textbox` doesn't work in certain case: focus problem!

Open mytzenka opened this issue 5 years ago • 3 comments

Describe the bug Normally the keyword input text to textbox works fine, but I found a 'special' case in which it doesn't.

To Reproduce Take the following test suite (you will need to change the locators to your local language):

*** Settings ***
Library  WhiteLibrary

*** Test Cases ***
Open Notepad with WhiteLibrary
    launch application  C:/Windows/System32/notepad.exe
    attach window  Naamloos - Kladblok
    sleep  3s   # During this time, manually click twice on the start menu button so that it has the focus
                # Now you will see that the next keyword fails (doesn't input the text) because it cannot 'grab' the focus
    input text to textbox  text:Teksteditor  Hello World!
    ${text}  get text from textbox  text:Teksteditor
    should be equal as strings  ${text}  Hello World!
    click menu button  text:Bestand
    click menu button  text:Afsluiten
    click button  text:Niet opslaan

If you execute this 'as is' it works fine. However, if you click twice on the Windows 10 start menu button so that it keeps the focus, you will find that the input text to textbox doesn't enter any text.

Apparently this is because the keyword enters text by sending keystrokes to whatever element currently has the focus and when the start menu button has the focus, then for some obscure reason it cannot 'grab' the focus, but also doesn't fail because it simply sends keystrokes into the void.

Expected behavior The text is entered into the control given by the locator, regardless of where the current focus is at.

Workaround I can 'solve' this by explicitly setting the focus to the Notepad window. There isn't a set focus keyword (yet?), so I now do this by using mouse click 10 10 on the window.

Desktop Windows 10 Enterprise 1703

mytzenka avatar Mar 18 '19 06:03 mytzenka