Unable to cast object of type 'TestStack.White.UIItems.TabItems.TabPage' to type 'TestStack.White.UIItems.Button'

144 views Asked by At

I am new to c# and automation.I am trying to automate a process in an app. I found automation id of an element using inspect.exe and tried the following code to click the element

public void import_Enc(string excelPath, string fileName, string impConfig, 
                       string[] ImportEnclosures, Window mainwindow)
{
    SearchCriteria search1 = SearchCriteria.ByAutomationId("Libraries");
    Button button = (Button)mainwindow.Get(search1);
    button.Click();           
    importEnclosure(excelPath, fileName, impConfig, ImportEnclosures);
}

When i run the test i got an error

System.InvalidCastException: 'Unable to cast object of type 'TestStack.White.UIItems.TabItems.TabPage' to type 'TestStack.White.UIItems.Button'.'

I have tried to look for cast type of TabPage in Teststack.White but i didn't find any,do u have any idea?

0

There are 0 answers