Keyboard pops error when chromeheadless but work for chrome

1 Answer 17 Views
Chrome
Jun
Top achievements
Rank 1
Iron
Jun asked on 10 May 2024, 03:23 AM

Hi Team,

I am trying chromeheadless now, most of the UI operations could work, but for keybord, which do not work, like below:

Manager.Current.Desktop.KeyBoard.KeyDown(Keys.Alt);
Manager.Current.Desktop.KeyBoard.KeyPress(Keys.End);
Manager.Current.Desktop.KeyBoard.KeyUp(Keys.Alt);

 

It's not always broken, when I use it in my case, the same code work for chrome, but broken for chromeheadless, i don't know how to debug the issue. Can you please help to check for us?

Message: 
    ExecuteCommand failed!
    InError set by the client. Client Error:
    Protocol error (Input.dispatchKeyEvent): Invalid 'text' parameter
    BrowserCommand (Type:'Action',Info:'NotSet',Action:'RealKeyboardAction',Target:'null',Data:'keyDown#$TS$#LMenu',ClientId:'1748F9AF024B6615B325B7310DF45C36',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'Protocol error (Input.dispatchKeyEvent): Invalid 'text' parameter')
    InnerException: none.


  Stack Trace: 
    ArtOfTest.WebAii.Exceptions.ExecuteCommandException: ExecuteCommand failed!
    InError set by the client. Client Error:
    Protocol error (Input.dispatchKeyEvent): Invalid 'text' parameter
    BrowserCommand (Type:'Action',Info:'NotSet',Action:'RealKeyboardAction',Target:'null',Data:'keyDown#$TS$#LMenu',ClientId:'1748F9AF024B6615B325B7310DF45C36',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'Protocol error (Input.dispatchKeyEvent): Invalid 'text' parameter')
    InnerException: none.
    Browser.ExecuteCommandInternal(BrowserCommand request)
    Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
    HeadlessKeyboard.PressOrReleaseKey(Keys key, Boolean release)
    KeyBoard.KeyDown(Keys code, Boolean delay)
    KeyBoard.KeyDown(Keys key)
    <.ctor>b__26_8() line 106

 

Thanks,

Jun

    

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 14 May 2024, 01:53 PM

Hello Jun,

There's one important thing for using the key presses within a web test - these need to be sent to handle some actions within the application. If there is anything outside of the web page that accepts key presses (for example, interacting with the browser menus and tools), it cannot be handled in Chrome headless and extensionless modes. 

As to the Alt key press - you are right that currently this isn't working for headless and extensionless test runs. Thus I submitted a public bug report item on your behalf. You can find the item here and follow its progress. 

Thank you for your understanding in advance. 

Regards,
Elena
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Jun
Top achievements
Rank 1
Iron
commented on 15 May 2024, 02:59 AM | edited

Hi Elena,

Thanks you for update. 

Yes, after test we find the keyboard for switch chrome tab not work, which should be the reason you mentioned above, "If there is anything outside of the web page that accepts key presses (for example, interacting with the browser menus and tools), it cannot be handled in Chrome headless and extensionless modes.", we use brower.close instead.

And for Alt keyboard, thanks for raising a ticket. We will also check if any workaround way.

 

Another finding we wants to share with you, maybe you can give more meaningful explanation. We found download operations, chomeheadless is more like IE than chrome. For example, IE will pop up a dialog, but chrome copy directly to default download path. And for chromeheadless, original IE coke could work well, but chrome code will fail.

Elena
Telerik team
commented on 16 May 2024, 10:43 AM

Hi Jun, 

The keyboard key presses cannot be used to interact with the browser options for headless and extensionless test runs with Chrome and Edge. These will only work if the specific keys trigger something in the tested page. 

I am not sure what you mean by saying that switching the browser tabs is not working - in your other thread on that topic I shared a sample which works fine to perform all actions. The only thing is that the tabs are not visually changed if running the test in headless and extensionless test runs with Chrome and Edge, but shouldn't be an issue if still the needed actions are in place in the expected tab. 

As to the download handling - the outcome is the same for all browsers and different type of execution. What differs is the visual representation and it is as follows: 

  • IE, Firefox and Chrome and Edge with extension handle the download dialog visually as if a user does this - the dialog appears and the full file path gets entered to save the file.
  • Chrome and Edge in headless and extensionless modes handle the download dialog in the background - no dialog appears, but the file is saved with the full file path listed in the dialog handler action. 

I am not aware what code you are using to handle the dialogs, but the one we recommend and support is using the built-in DownloadDialogsHandler class. So, if you are using anything else, take the time to update it accordingly. 

I hope this information helps you sort out your doubts.

Regards,
Elena

Tags
Chrome
Asked by
Jun
Top achievements
Rank 1
Iron
Answers by
Elena
Telerik team
Share this question
or