简体   繁体   中英

How to record multiple clicks while holding shift (or any other button) using Coded UI Tests?

I have a grid-component which has a multiple-column-sort feature. The multi-column-sort feature is activated by:

  1. Press and hold shift key
  2. Click two or more columns (while holding the shift-key)
  3. Release the shift key -> Multiple sort is activated

I tried to record this using coded-ui-tests but the recording was like this:

  1. Shift press and hold 1 + Click on column 1
  2. Shift press and hold 2 + Click on column 2

So the coded ui test builder does not seem to grasp that I'm actually holding the shift-button. Has anyone had a similar problem? Is there a workaround?

I think you can use:

Keyboard.PressModifierKeys(ModifierKeys.SHIFT);
Mouse.Click
Mouse.Click
Keyboard.ReleaseModifierKeys(ModifierKeys.SHIFT);

PressModifierKeys: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.keyboard.pressmodifierkeys.aspx

ReleaseModifierKeys: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.keyboard.releasemodifierkeys.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM