Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to Access button present in WPF cell of WPF table in coded UI?

$
0
0
 

I am Testing WPF Application using Coded UI.. My testcase is like verifying whether button is enabled or not. wpf button is present in wpftcell which is in the wpftable.

The hirarichy of the button is like

UIitemtable-->UIdataItem-->UIcell-->UIbutton

I have written my test method like

public void VerificationOfSingledeviceSearch()
        {
            ResultsPageClasses.ResultsPage Objresultpage = new ResultsPageClasses.ResultsPage();

            WpfButton btninstall = Objresultpage.UISalesforceConnectorVWindow.UIItemTable.UIItemDataItem.UIItemCell.UIInstallButton;
            WpfButton btnunInstall = Objresultpage.UISalesforceConnectorVWindow.UIItemTable.UIItemDataItem.UIItemCell.UIUninstallButton;
            WpfCell cell = Objresultpage.UISalesforceConnectorVWindow.UIItemTable.UIItemDataItem.UIItemCell;
            WpfTable table=Objresultpage.UISalesforceConnectorVWindow.UIItemTable;
            WpfControl dataitem = Objresultpage.UISalesforceConnectorVWindow.UIItemTable.UIItemDataItem;
if(btnunInstall.Enabled)
            {
                Console.Write("pass");
            }}

if run Above code the test is failed.

 Failed
Result Message: 
Test method ESAC_Test.TestMethods.VerificationOfSingledeviceSearch threw exception:
System.ArgumentException: No row was specified as search container for the control. To search for a cell control using 'ColumnIndex', you must specify row as a container element or add 'RowIndex' to the search property of the cell.
Parameter name: SearchProperties

then I have include following code

public void   VerificationOfSingledeviceSearch()      {
            ResultsPageClasses.ResultsPage Objresultpage = new ResultsPageClasses.ResultsPage();

            WpfTable table = Objresultpage.UISalesforceConnectorVWindow.UIItemTable;
            WpfCell cell = Objresultpage.UISalesforceConnectorVWindow.UIItemTable.UIItemDataItem.UIItemCell;
            WpfControl row = Objresultpage.UISalesforceConnectorVWindow.UIItemTable.UIItemDataItem;

           
            row.SearchProperties.Add("Controltype", "DataItem");
           
            cell.Container = table;
            cell.SearchProperties.Add("ControlType", "Cell");
            cell.SearchProperties.Add("RowIndex", "0");
            cell.SearchProperties.Add("ColumnIndex", "4");
            cell.DrawHighlight();
        }

Test Name: VerificationOfSingledeviceSearch
Test Outcome: Failed
Result Message: 
Test method ESAC_Test.TestMethods.VerificationOfSingledeviceSearch threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName:  'UIA'
ColumnHeader:  ''
ControlType:  'Cell'
RowIndex:  '0'
ColumnIndex:  '4'
 Search may have failed at '' Table as it may have virtualized children. If the control being searched is descendant of '' Table then including it as the parent container may solve the problem. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

Can anyone suggest me to solve above isssue?



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>