Forum Discussion
Is it possible for you to post the code itself that is generating the error?
- krkarthik_info9 years agoFrequent Contributor
Hi Robert,
//Select the 1st Row(Row 0) in Main Grid Aliases.w_FS.HwndSource_Shell.Shell.RibbonWindowContentHost.Grid.ItemsControl.ContentPresenter.MainView.Grid.dockManager.SplitPane.ContentPane_1.RawFileTabView.Grid.XamDockManager.SplitPane.TabGroupPane.ContentPane_1.ContentControl.CompositeRawFileView.CompositeContents.dockManager.sp.WPFObject("mzVaultSearchResults").WPFObject("ContentControl", "", 1).WPFObject("MzLibrarySearchResultsWindow").WPFObject("Grid", "", 1).WPFObject("MzVaultSearchResultsGrid").ClickRowIndicator(0); aqUtils.Delay(1000); //Expand the 1st Row(Row 0) Aliases.w_FS.HwndSource_Shell.Shell.RibbonWindowContentHost.Grid.ItemsControl.ContentPresenter.MainView.Grid.dockManager.SplitPane.ContentPane_1.RawFileTabView.Grid.XamDockManager.SplitPane.TabGroupPane.ContentPane_1.ContentControl.CompositeRawFileView.CompositeContents.dockManager.sp.WPFObject("mzVaultSearchResults").WPFObject("ContentControl", "", 1).WPFObject("MzLibrarySearchResultsWindow").WPFObject("Grid", "", 1).WPFObject("MzVaultSearchResultsGrid").Expand(0, true); aqUtils.Delay(2000); //Select the 3rd row in sub grid Aliases.w_FS.HwndSource_Shell.Shell.RibbonWindowContentHost.Grid.ItemsControl.ContentPresenter.MainView.Grid.dockManager.SplitPane.ContentPane_1.RawFileTabView.Grid.XamDockManager.SplitPane.TabGroupPane.ContentPane_1.ContentControl.CompositeRawFileView.CompositeContents.dockManager.sp.mzVaultSearchResults.MzVaultSearchResultsGrid.ExpandableFieldRecordPresenter.ClickRowIndicator(2);
On select the row in the sub grid returns that error.
Thanks,
Karthik K R
- tristaanogre9 years agoEsteemed Contributor
OK, first of all, just a format note... for readability, you might want to compress your Alias pathing for your objects. A lot of the objects and such that you have in the current paths are probably not ones you are going to be interacting with in your automation so it's better to use the Alias feature to your advantage and collapse them down.
That said, the code looks pretty good for the most part. However, it is possible that the 2 second hardcoded delay is not long enough. Rather than using hardcoded delays, you might want to use WaitAliasChild to do a more dynamic way of checking for the object. So... your last section of code I would write as:
//Select the 3rd row in sub grid Aliases.w_FS.HwndSource_Shell.Shell.RibbonWindowCo
ntentHost.Grid.ItemsControl.ContentPresenter.MainV iew.Grid.dockManager.SplitPane.ContentPane_1.RawFi leTabView.Grid.XamDockManager.SplitPane.TabGroupPa ne.ContentPane_1.ContentControl.CompositeRawFileVi ew.CompositeContents.dockManager.sp.mzVaultSearchR esults.MzVaultSearchResultsGrid.WaitAliasChild("ExpandableFieldRecordPresenter", 10000).ClickRowIndicator(2); Probably better practice would write code to detect if the object exists before attempting to interact with it. I would do the same for your other code sections as well.... detect if the objects exist using WaitAliasChild rather than using a hard coded delay.
At least, this would be a first step in troubleshooting your problem. It might not fix it directly, but it will at least clean things up a bit and add reliability back into your automation.
- krkarthik_info9 years agoFrequent Contributor
Hi Robert,
Thanks for your input.
I have found wChildView extended property of my first grid, which helped me to get the row count and column count of the child grid with the code below.
Also I can use ClickRowIndicator() method with the below code
Aliases.w_FS.HwndSource_Shell.Shell.RibbonWindowContentHost.Grid.ItemsControl.ContentPresenter.MainView.Grid.dockManager.SplitPane.ContentPane_1.RawFileTabView.Grid.XamDockManager.SplitPane.TabGroupPane.ContentPane_1.ContentControl.CompositeRawFileView.CompositeContents.dockManager.sp.mzVaultSearchResults.MzVaultSearchResultsGrid.wChildView(0).wChildView(0).wColumnCount
Thanks,
Karthik K R