Wednesday, 15 April 2009
How to reduce a Test Automation Deficit
Thursday, 12 February 2009
WatiN 2.0 - CTP Release 3.0
WatiN just keeps getting better with the latest release. WatiN 2.0 CTP 3.0, now offers increased support for both Internet Explorer and FireFox.
Changes in this release:
- Implemented support on Mozilla.Frame to get access to elements inside the document of a Frame
- Implemented support on Mozilla.Frame to get access to elements inside the document of an IFrame
- Implemented Eval on Mozilla.Document (= FireFox and Frame) and added to the IFrame interface
Fixed bug(s):
WatiN - Firefox with iFrames
I’ve been trying to get my head back into WatiN (WatiN-2.0.1.754-net-2.0) recently, and came across an issue trying to get hold of the contents of an IFrame. Using IE, I was able to use an Assert to check the contents of an IPara which resides within an IFrame. However, running the same code against Firefox, I was unable to get inside ‘Mainwin’, even though FireBug can see it without issue.
However, having posted a message on the WatiN Users (Sourceforge) Forum, Jeroen van Menen has advised that the next CTP release of WatiN will support iFrames.
[Test]
public void CheckSplashContentTelephone()
{
IBrowser browser = BrowserFactory.Create(BrowserType.FireFox);
browser.GoTo(_loginUri);
browser.Maximize();
Thread.Sleep(3000);
Common.LogOn.ImportControl(browser, "Click Here to Skip Download");
Assert.AreEqual(Splash.Telephone(browser).Text.Trim(), "My Phone Number");
Toolbar.ClickButton(browser, Toolbar.Button.LOGOUT);
browser.Close();
}
public static IPara Telephone(IBrowser browser)
{
IFrame mainframe = browser.Frame(Find.ById(mainwin));
return mainframe.Paras[1];
}
Friday, 16 January 2009
WatiN 2.0 - CTP Release 2.0
Changes in this release:
- - Works with FireFox 3.x and FireFox 2.x (both jssh.xpi plug-ins are included in the Mozilla directory)
- - Greatly improved performance and stability when running tests with FireFox
Fixes reported bugs:
- Problem with setting ActiveElement in FF 3.x
- SF issue 1954487 Setting TextField.Value for TextArea in FireFox fails
- SF issue 1913072 BrowserFactory.Settings.WaitForCompleteTimeOut doesn't work
Wednesday, 10 September 2008
WatiN - Running IISReset
| There might be ocassion where there's a need to run an IISReset as part of your Test. Here's how you do it. { // Run IIS reset to clear the chache Process iisResetProcess = System.Diagnostics.Process.Start("cmd.exe", ConfigurationManager.AppSettings["iisResetCommand"].ToString()); iisResetProcess.WaitForExit(); iisResetProcess.Close(); } In order to allow this to work, please ensure that your App.Config has the following within |
Monday, 28 July 2008
WatiN - Simple SQL Server Class
namespace Common
{
public class SQLServer
{
private SqlConnection _sqlConn;
public SqlConnection myConnection
{
get
{
if (_sqlConn.State != System.Data.ConnectionState.Open)
{
_sqlConn.Open();
}
return _sqlConn;
}
}
public void CONNECT(string uname, string pword, string dbserver, bool isTrustedConnection, string database, int connTimeout)
{
string connStr = string.Empty;
if (isTrustedConnection)
{
connStr = " server=" + dbserver + "; Trusted_Connection=yes" + "; database=" + database + "; connection timeout=" + connTimeout.ToString();
}
else
{
connStr = " user id=" + uname + "; password=" + pword + "; server=" + dbserver + "; database=" + database + "; connection timeout=" + connTimeout.ToString();
}
_sqlConn = new SqlConnection(connStr);
try
{
_sqlConn.Open();
}
catch (Exception ex)
{
Console.WriteLine("Connection string not valid:" + connStr);
}
}
public void DISCONNECT()
{
myConnection.Close();
}
public string SELECT(string tableName, string columnName, string fieldname, string value)
{
string sqlStr = string.Empty;
sqlStr = " SELECT [" + fieldname + "] FROM [" + tableName + "] WHERE [" + columnName + "]= '" + value+"'";
SqlCommand sqlComm = new SqlCommand(sqlStr, myConnection);
object o = sqlComm.ExecuteScalar();
if (o == null)
return string.Empty;
else
return o.ToString();
}
public System.Data.DataTable SelectMultipleValues(string tableName, string columnName, string[] fieldNames, string[] critieraValues)
{
System.Data.DataTable values = null;
string sqlStr = " SELECT ";
foreach(string fieldName in fieldNames)
{
sqlStr+="[" + fieldName + "], ";
}
if (sqlStr.EndsWith(", "))
{
sqlStr = sqlStr.Substring(0, sqlStr.Length - 2);
}
sqlStr += " FROM [" + tableName + "] WHERE [" + columnName + "] IN(";
foreach (string criteriaValue in critieraValues)
{
sqlStr += "'" + criteriaValue + "',";
}
if (sqlStr.EndsWith(","))
{
sqlStr = sqlStr.Substring(0, sqlStr.Length - 1);
}
sqlStr += ")";
SqlCommand sqlComm = new SqlCommand(sqlStr, myConnection);
SqlDataReader reader = sqlComm.ExecuteReader();
if (reader != null && reader.HasRows)
{
values = GetTable(reader);
reader.Close();
}
return values;
}
public System.Data.DataTable GetTable(System.Data.SqlClient.SqlDataReader _reader)
{
System.Data.DataTable _table = _reader.GetSchemaTable();
System.Data.DataTable _dt = new System.Data.DataTable();
System.Data.DataColumn _dc;
System.Data.DataRow _row;
System.Collections.ArrayList _al = new System.Collections.ArrayList();
for (int i = 0; i < _table.Rows.Count; i++)
{
_dc = new System.Data.DataColumn();
if (!_dt.Columns.Contains(_table.Rows[i]["ColumnName"].ToString()))
{
_dc.ColumnName = _table.Rows[i]["ColumnName"].ToString();
_dc.Unique = Convert.ToBoolean(_table.Rows[i]["IsUnique"]);
_dc.AllowDBNull = Convert.ToBoolean(_table.Rows[i]["AllowDBNull"]);
_dc.ReadOnly = Convert.ToBoolean(_table.Rows[i]["IsReadOnly"]);
_al.Add(_dc.ColumnName);
_dt.Columns.Add(_dc);
}
}
while (_reader.Read())
{
_row = _dt.NewRow();
for (int i = 0; i < _al.Count; i++)
{
_row[((System.String)_al[i])] = _reader[(System.String)_al[i]];
}
_dt.Rows.Add(_row);
}
return _dt;
}
}
}
How do I use the Class?public static void SelectValues()
{
Common.SQLServer sq = new Common.SQLServer();
sq.CONNECT("sa", "sa", "SQLServerInstance", true, "Database", 10);
string[] fieldNames = { "ColumnValue" };
string[] criteriaValues = { "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8" };
System.Data.DataTable result = sq.SelectMultipleValues("Option", "Name", fieldNames, criteriaValues);
foreach (System.Data.DataRow row in result.Select())
{
foreach (System.Data.DataColumn column in result.Columns)
{
Console.WriteLine((string)row[column]);
}
}
sq.DISCONNECT();
}
Thursday, 10 July 2008
Agile Testing - why do it any other way?
More recently, my company 'Immediacy' (or Alterian as we're now known) has been using SCRUM, which is a Lightweight Management Framework that makes it really easy to demonstrate the progress of the project to both you and your customer. I certainly couldn't go back to the archaic practices of Waterfall, or 'dumping over the fence' as I've often been known to refer it to.
My boss sent me this useful Google Video recently, which is a really good insight into Testing in an Agile environment. Give it a watch.........it's really interesting.
Agile Testing Video
Scrum Alliance
