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
578 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

815 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

12 Experts available now in Live!

Get 1:1 Help Now