Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample snippet used in Coded UI Test for an Excel COM add-in
// Launch Excel 2016 from '%ProgramFiles%\Microsoft Office\root\Office16\EXCEL.EXE'
ApplicationUnderTest excelApp = ApplicationUnderTest.Launch(this.StartAndQuitExcelParams.ExePath, this.StartAndQuitExcelParams.AlternateExePath);
// After Excel loads, click the 'Blank workbook' list item
Mouse.Click(blankWorkbookListItem, new Point(117, 182));
// Select your add-in's ribbon tab
Mouse.Click(myAddinRibbonTab, new Point(276, 771));
// Click a control on your add-in's ribbon, in order to display the VBA userform
Mouse.Click(myHelloWorldControl, new Point(305, 72));
// Now that the userform is shown, populate the two textboxes with values
myFirstNameTextBox.Text = "John";
myLastNameTextBox.Text = "Doe";
// Press "OK" on the userform, and validate the UI behaves as expected
//...
// Here the test can succeed or fail, which is exactly what we want!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment