Script is not executed when ‘Nunit’ item is added to ‘Unit Test Project’
Please find below steps
9. Script is not at all executing and not even browser is invoked
Sample Script:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.ObjectModel;
using ArtOfTest.WebAii.TestAttributes;
using ArtOfTest.WebAii.TestTemplates;
using ArtOfTest.WebAii.Win32.Dialogs;
using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.Silverlight.UI;
using NUnit.Framework;
using Core = NUnit.Core;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Sampe1
{
/// <summary>
/// Summary description for TelerikNUnitTest1
/// </summary>
[TestFixture]
public class TelerikNUnitTest1 : BaseTest
{
#region [Setup / TearDown]
/// <summary>
/// Initialization for each test.
/// </summary>
[SetUp]
public void MyTestInitialize()
{
#region WebAii Initialization
Initialize(false, new TestContextWriteLine(Console.Out.WriteLine));
#endregion
}
[TearDown]
public void MyTestCleanUp()
{
#region WebAii CleanUp
// Shuts down WebAii manager and closes all browsers currently running
this.CleanUp();
#endregion
}
[TestFixtureTearDown]
public void FixtureCleanup()
{
ShutDown();
}
#endregion
[Test]
public void SampleWebAiiTest()
{
// Launch a browser instance
Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
// Navigate the active browser to www.wikipedia.org
ActiveBrowser.NavigateTo("http://www.wikipedia.org/");
// Find the wikipedia search box and set it to "Telerik Test Studio";
Find.ById<HtmlInputSearch>("searchInput").Text = "Telerik Test Studio";
// Click the search arrow button
Find.ByName<HtmlInputSubmit>("go").Click();
// Validate that search contains 'Telerik Test Studio'
// Assert.IsTrue(ActiveBrowser.ContainsText("Telerik Test Studio"));
//Read more here:
//http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/intermediate-topics/element-identification/finding-page-elements.aspx
}
}
}
Please guide me how to run script using Nunit(Telerik Test Framework) in 'Unit Test Project'
//Get the mandatory field: family name
var familyName = Client.Browser.Find.ByAttributes<HtmlInputText>(
"id=FamilyName"
);
//Enter some text
Client.Browser.Actions.SetText(familyName,
"Chrome and Firefox problems"
);
//Trigger a bunch of jquery events that indicate the control has changed
familyName.InvokeEvent(ArtOfTest.WebAii.Core.ScriptEventType.OnChange);
familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.keydown);
familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.keyup);
familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.keypress);
familyName.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.change);
string
userName = TestContext.DataRow[
"Username"
].ToString();
ActiveBrowser.NavigateTo(
"~/User/LogInPage.aspx"
);
HtmlFindExpression untbExpr =
new
HtmlFindExpression(
"id=?RadTextBoxUserName_wrapper"
);
ActiveBrowser.WaitForElement(untbExpr, 30000,
false
);
RadTextBox usernameTb = ActiveBrowser.Find.ByExpression<RadTextBox>(untbExpr);
usernameTb.Clear();
usernameTb.TypeText(userName);
HtmlFindExpression lbExpr =
new
HtmlFindExpression(
"id=?RadButtonLogin_input"
);
ActiveBrowser.WaitForElement(lbExpr, 30000,
false
);
RadButton loginButton = ActiveBrowser.Find.ByExpression<RadButton>(lbExpr);
loginButton.MouseClick();
//Navigates to ~/Default.aspx but authenticated.
//Throws error
HtmlFindExpression expr =
new
HtmlFindExpression(
"id=?RadToolBarMain"
);
ActiveBrowser.WaitForElement(expr, 30000,
false
);
RadToolBar tb = ActiveBrowser.Find.ByExpression<RadToolBar>(expr);
RadToolBarItem lob = tb.FindItemByText(
"Log Off"
);
//WORKS!!!
//HtmlFindExpression loButton = new HtmlFindExpression("title=^Log Off", "class=rtbWrap");
//ActiveBrowser.WaitForElement(loButton, 30000, false);
//HtmlAnchor lob = ActiveBrowser.Find.ByExpression<HtmlAnchor>(loButton);
//lob.MouseHover();