Solved

How to get list of opened workbooks in an Excel 2010 application using Coded UI Tests in Visual Studio 2010?

Posted on 2011-09-19
4
574 Views
Last Modified: 2013-12-13
Hello,

I have created a test project with Visual Studio 2010 Premium to test an Excel 2010 add-in. i'm using Coded UI Tests to automate the testing, and I'd like to get the list of the opened workbooks in a one of the tests.

I was thinking that I could get the names of the opened workbooks from the View->Switch Windows button, as we can see below:
 View-Switch Windows screenshot
But when I track the UI control using the Microsoft UI Test Builder, I don't find how to get the elements of the list displayed when clicking the DropDownButton control:
 Coded UI Test Builder
It would be simpler if I could get it by accessing the excel application object in C#, but I don't know either how to do this, as the application is executed from the UIMap object:
 Launch Excel 2010
Can you please help?
Thanks in advance,
Julien
0
Comment
Question by:JulienVan
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
akoster earned 500 total points
ID: 36567461
Regularly I would expect the opened workbooks to be stored in the excel.workbooks object.
I do not know however if this object is available from within the test environment...
0
 
LVL 2

Assisted Solution

by:JulienVan
JulienVan earned 0 total points
ID: 36567593
Hi Akoster, the problem came from the fact that I wanted to convert the Excel application object created by the coded ui test editor (type Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinWindow) into a Microsoft.Office.Interop.Excel.Application object.

Thanks to your comment, I tried to create the excel application using a new instance of the class Microsoft.Office.Interop.Excel.Application, and it works fine. I've just replaced the first test step (opening excel) by two lines of code, and I'm an happy man now!

I'm going to close the question, thanks for your help.
0
 
LVL 2

Author Closing Comment

by:JulienVan
ID: 36594679
I've added my comment as part of the solution
0
 
LVL 19

Expert Comment

by:akoster
ID: 36567740
you're welcome !
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now