Wednesday, September 05, 2012 8:46 PM
I want to run my application and write certain values from the application to a data table (I don't really care what type i.e. csv, excel, etc..)so that in later runs I can use those values as expected results.
Is this possible in Coded UI?
Wednesday, September 05, 2012 9:17 PM
Please share some more details about your requirement. Do you want to run some CodeUI test on the application and during the test fetch and store some values generated by application during the run-time?
Utility to run CUIT Ordered Tests for multiple iterations (Now with automated result mailing) @ http://cuitbatchrunner.codeplex.com/
Friday, September 07, 2012 8:14 AMModerator
Thanks for Pankaj’s help.
It seems that you want to input the value to a data source with app1, and then use the data source in your coded UI test project, am I right?
As far as I know, it would support it, as my understanding, it is similar to that we want to edit the data source value before running the coded UI test. One idea is that we could change it with ADO.NET knowledge, if you want to insert value to a data source, maybe this document could provide some information, see “Inserting an Image from a File (ADO.NET)”.
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Friday, September 14, 2012 2:29 AM
Friday, September 07, 2012 2:12 PM
Pankaj is correct. I want to run the app and fetch data from the app and store it in a data source then later use that data source as my expected results. I'll look at teh link that Jack provided and see if it will help.
Monday, September 10, 2012 5:59 AMModerator
I am writing to check the status of the issue on your side.
What about this problem now?
Would you mind letting us know the result of the suggestion?
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
Thursday, September 20, 2012 9:25 PM
I just saw your post, and thought I'd throw my two cents in. Sorry for the length. What you're trying to do is not only possible, it's my preferred method of running automated scripts. My entire automation suite is loaded into an Access database. Each test script is stored as a series of database records (i.e., test steps) that includes what Module (web page) is active, what data verification needs to be done, what data to input, what action to perform, and (most importantly in your case) any Access database queries or updates to be performed.
I have a whole series of data preparation automated scripts that I run just to prep the test environment for the actual Shakeout and Functional test scripts. The data prep scripts create specific types of defects, search for existing parts information, PO information, existing defects, etc. The information compiled by these scripts gets loaded into appropriate data prep tables in the Access database, and are then retrieved by the Shakeout and Functional scripts at execution time for use as dynamic input data.
This is a slightly simplified version of the main driver. I got rid of some minor logging details, but this is essentially the entire driver. All it does is read and execute the test step information from the Access database:
[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\APPData\\APPData_be.accdb", "ExecutionList", DataAccessMethod.Sequential), TestMethod]
public void AUTTest()
foreach (var testCaseStepsRow in _steps)
string module = _namespace + _utility.GetModuleName(testCaseStepsRow.ModuleID);
object map = _data.GetObject(module);
Dictionary<string, Dictionary<FieldObject, string>> test = _utility.GetTestStepData(testCaseStepsRow.ModuleDataID, testCaseStepsRow.ModuleID, _global, map);
_data.DoVerification(test["ModuleVerification"], map, _global, stepNumber);
_data.EnterData(test["ModuleData"], map, _global, stepNumber);
_data.PerformAction(test["ModuleAction"], map, _global, stepNumber);
catch (CodedUIException ex)
throw new PlaybackFailureException(ex.Message);
catch (Exception e)
The actual Access database connection is pretty simple, as is executing standard SQL commands to retrieve or update the Access tables. Retrieving information from the database is done like this:
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\APPData\\APPData_be.accdb");
dq = new DynamicQueryExecution(conn, new OleDbCommand(query, conn));
Updating the database tables is done like this:
dq.ExecuteDynamicQuery(query, 1, flag, 0, 0);
The keyword "query" is either a standard SELECT or UPDATE command. (Since my test scripts are stored in the Access database, I can execute SQL commands wherever I need to as part of a particular test script step.)
The ExecuteDynamicQuery Method looks like this (leaving out some extraneous code like the random selection stuff):
/// The DynamicQueryExecution class is where we connect to the Microsoft
/// Access back-end database, perform any queries on it, and return the
/// This method takes a string (the SQL command, an integer depicting
/// the length of the array of retrieved values, a flag that determines
/// if we are randomly picking a retrieved value, concatenating the result
/// set, or picking the first value, and integer range information for
/// random selection. We then return the result set back to the calling
private DbConnection conn;
private DbCommand command;
private DbDataReader reader;
public DynamicQueryExecution(DbConnection conn, DbCommand command)
this.conn = conn;
this.command = command;
/// <param name="queryString">The sql query string to be executed</param>
/// <param name="queryReturns">The length of the query returns array</param>
/// <param name="flag">The output handler flag</param>
/// <param name="RangeFrom">The random selection lower range</param>
/// <param name="RangeTo">The random selection upper range</param>
/// <returns>An array of objects that was returned from the query</returns>
public object ExecuteDynamicQuery(string queryString, int queryReturns, ReturnTypeEnum flag, int RangeFrom, int RangeTo)
reader = command.ExecuteReader();
object returnValues = new object[queryReturns];
returnValues = new object[queryReturns];
The returned information (from SELECT statements) gets loaded into a global variables dictionary to be used by other test steps as dynamic input data. (The UPDATE commands don't need to return any data, since all they do is update a database record.)
Hope this helped you a little, anyway. Good luck.
Friday, September 21, 2012 6:07 PMThanks for that info. I haven't had a chance to get on this as I've been pulled in other directions but I will be getting back to this soon.