My company picked up a few licenses of the tool so I'm new to the tool. I'm trying to run the following coded step to reset the database to a baseline state. I will have a sql script to do that but I would like to incorporate a coded step to call the SQL script. Below is some code I found on the web to do that. I'm not a developer so I'm probably doing something wrong. Every time I run the test I get the following error message: "Execution Stage:Execution , unexpected error during test execution. Error: System.ArgumentException: The coded step method 'SQLReset' does not exist.
at ArtOfTest.WebAii.Design.Execution.ExecutionContext.SetNewBrowserTracking(Test test, Object codeBehind)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.InternalExecuteTest(Object codeBehindInstance)
at ArtOfTest.WebAii.Design.Execution.TestExecuteProxy.ExecuteTest(Test test, Settings settings, String deploymentFolder, ExecutionType exeType)"
Coded Step:
using
System;
using System.Collections.Generic;
using System.Text;
using ArtOfTest.Common.UnitTesting;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
using ArtOfTest.WebAii.Design;
using ArtOfTest.WebAii.Design.Execution;
using ArtOfTest.WebAii.ObjectModel;
using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.Silverlight.UI;
using Telerik.WebAii.Controls.Html;
using Telerik.WebAii.Controls.Xaml;
using System.Data.SqlClient;
using System.IO;
namespace DBI_Automation.BPO.Automation
{
public class SQLReset : BaseWebAiiTest
{
[
CodedStep(@"Run SQL Script to reset database")]
protected void SQLResetCall(object sender, EventArgs e)
{
//SqlConnection con = new SqlConnection(@"Server=.\SQLEXPRESS;Database=" + txtSqlName.Value + ";User ID=" + txtSqlLogin.Value + ";Password=" + txtSqlPassword.Text + ";Trusted_Connection=False");
SqlConnection con = new SqlConnection(@"Server=DET-3176\MSSQL2008;Database=Test;Trusted_Connection=True");
con.Open();
string FilePath;
FilePath =
@"\\urbanscience.net\users\DET\atbeard\Documents\SQL Server Management Studio\Projects\TestSQLQuery.sql";
//FilePath = @"C:\Inetpub\vhosts\" + dsAdministration.Tables[0].Rows[0]["Domain"].ToString() + @"\httpdocs\users\" + Session["UserId"].ToString() + @"\" + Session["Domain"].ToString() + @"\css\" + lnkName.Text;
if (File.Exists(FilePath))
{
StringBuilder strStatement = new StringBuilder(File.ReadAllText(FilePath).ToString());
SqlCommand command = new SqlCommand(strStatement.ToString(), con);
command.ExecuteNonQuery();
con.Close();
}
}
}
}
*Editted because it was difficult to read