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

I have a grid component that has a multi-column sort functionality. The sort function of multiple columns is activated:

  • Press and hold the shift key
  • Click two or more columns (while holding the shift key)
  • Release the shift key → multiple sort activated

I tried to write this using coded ui tests, but the writing was like this:

  • Nudge press and hold 1 + Click column 1
  • Nudge press and hold 2 + Click column 2

So the ui coded test constructor doesn't seem to understand that I am actually holding the shift key. Has anyone had a similar problem? Is there a workaround?

+3


source to share


1 answer


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

+4


source







All Articles