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
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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