Help With Scrolling in an Application

Oct 14, 2013 at 7:54 PM
Edited Oct 14, 2013 at 8:29 PM
Hello,

I'm currently struggling with handling scrollbars in an application I'm testing. The object of interest is DataTable, which has a scrollbar attached to it - unfortunately, the only way I've found to handle the DataTable entries is by using Get-UIACustom -Value <value>. From there, I can, of course, click the items, save for those not in view. I tried using Invoke-UIACustomScrollItem, but I haven't been able to get anything to happen. I read Victor Woo's question and the corresponding responses (https://uiautomation.codeplex.com/discussions/461891), but since I have to get the objects as Custom items instead of as a List, I wasn't able to figure out how to apply the well-written responses to my own situation.

I'm currently running Windows 7 - any help would be greatly appreciated!

Thanks so much for your time,

-Jonathan

Edit: I'm trying to click an object outside of the currently displayed range. I'm currently attempting to use Set-UIAControlKeys to hit the down arrow button until $customObj | Read-UIAControlHasKeyboardFocus returns true, but I'd like to know whether a simpler and more efficient method exists.
Oct 14, 2013 at 8:44 PM
Hitting the down arrow button accomplished what I was looking for and the task is accomplished pretty quickly, so I'm good. I'd still like to know how to scroll, but for anybody else who might find the code helpful, here's what I did:
$table = <code to get DataTable element>
$dataElement = Get-UIACustom -Value <item value>

while ($($dataElement | Read-UIAControlHasKeyboardFocus) -ne $true) {
    $table | Set-UIAControlKeys -Text "{DOWN}"
}
Hope this helps!
Oct 14, 2013 at 9:27 PM
Thanks Jonathan!
I was pondering what to use to model the situation (and inclined to use Excel 2013, its sheet is UI Automation Tab with scroll), as your answer is already here! :)

From the question, I didn't get whether your DataTable implements or doesn't ScrollPattern. I understood that Custom elements don't support ScrollItemPattern.

There is no right way for any control to scroll it as only minority of controls support what they are supposed to support.
  • if a control (a container control like DataGrid, Table) supports ScrollPattern, we can use the Invoke-UIA[ControlType]Scroll cmdlet.
  • if an item (a child control like DataItem) supports ScrollItemPattern, we can use the Invoke-UIA[ControlType]ScrollItem cmdlet
    In other cases, we use what is possible:
  • keyboard as you just used (the Set-UIAFocus cmdlet may be used if necessary)
  • a Win32 click or InvokePattern (Invoke-UIA[ControlType]Click) on the upper or lower part of the scroll bar
  • a Win32 click or InvokePattern on the upper or lower button of the scroll control
Just a story: when I worked for Quest, these guys have bought legacy WinForms controls by Infragistics. I automated UltraGrid. The vendor refused to support UI Automation for these controls (it was 2011, nobody would invest in WinForms support as it was WPF+, Silverlight, etc era). There are a couple of cmdlets of those times in the framework. To select several rows in the grid, I used Ctrl + click inside the cmdlet (similarly to Invoke-UIAControlClick -Ctrl in PowerShell). It worked slowly, but finally it worked. The vendor offered only plugin for QTP or IBM RFT for $3k each (each tool itself costs $6-12k), so that my bosses were glad that I spent three or four days to produce a test engine for the grid and the need to approve an expensive tool has gone... :)
Oct 14, 2013 at 10:24 PM
Thanks for your quick reply - it's definitely appreciated (:

The DataTable does not implement ScrollPattern, it seems. So the only options would be one of those last three. May have to put a bug in the developer's ears about that!

I'm in a somewhat similar situation - the application I'm testing must be tested with no impact from third-party software... so I'm importing the UIA library from a CD and using the computer's native Powershell to run the scripts from CD.

Thanks again!