We have a customised infragristics grid in a siliver light application. The version of Sliverlight Application is 4.0
We are trying to select a row of this grid using QTP 10.0 having silver light add-in. We are sucessful in derriving row values of .IsSelected and .Is Active in following way -
msgbox Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.Rows.Item(0).IsActive
Above code gives "False" when the row is not clicked and "True" when the row is clicked.
msgbox Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.Rows.Item(0).IsSelected
Above code also, gives "False" when the row is not clicked and "True" when the row is clicked.
But when we try to use the QTP script to set it to Active or Selected using either of following code
Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.Rows.Item(0).IsActive = True
OR
Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.Rows.Item(0).IsSelected = True
We get following exception [Arg_ArgumentException]
Arguments:
Debugging resource stringsare unavailable. Often the key and arguments provide sufficient information to diagnose the problem see http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50917.0&File=mscorlib.dll&Key=Arg_ArgumentException
Line (60): "Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.Rows.Item(0).IsActive = True"
Seeking you advice in this case.
Hi,
I am guessing QTP accesses the Silverlight elements by using UIAutomation.
I am not sure how exectly this is done with QTP, but here is some C# code that we use to work with the UIAutomation support by the XamGrid:
AutomationPeer autoPeer = FrameworkElementAutomationPeer.CreatePeerForElement(grid.Rows[i].Control);
ISelectionItemProvider selectionProvider = (ISelectionItemProvider) autoPeer.GetPattern(PatternInterface. SelectionItem);
selectionProvider.Select();
selectionProvider.AddToSelection();
HTH,
We tred another approach suggested by the Dev team of this application
Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.SelectionSettings.SelectedRows.Add(Browser("iLocates").Page("iLocates").SlvWindow("Shell").SlvObject("LocatesGrid").Object.DataContext.LocatesGrid.Rows.Item(0)) but that did not help. It's throwing the same Error Again.
QTP uses vbscript in the background to access the appication objects properties and methods
Hello.
After looking at your code snippets above you are setting properties directly on the item itself. This means that you are getting a reference to the Silverlight object in the browser and at that point I don't think UI Automation is involved. I would contact HP support to see how accessing the Silverlight object directly will work when using QTP.
In the meantime, I have logged feature request #FR12864 to enable Test Advantage to work with Silverlight because at this time Test Advantage works only with Windows Forms.
Please let me know if you have any further questions.
Sincerely,CharlieSenior Developer Support EngineerMCTS