using System;using ArtOfTest.WebAii.Controls.HtmlControls;using ArtOfTest.WebAii.Core;using ArtOfTest.WebAii.TestTemplates;using NUnit.Framework;using Telerik.WebAii.Controls.Html;using Assert = ArtOfTest.Common.UnitTesting.Assert;namespace TelerikTestingFW{ /// <summary> /// Summary description for FirstStep /// </summary> [TestFixture] public class FirstStep : BaseTest { #region [Setup / TearDown] /// <summary> /// Initialization for each test. /// </summary> [SetUp] public void MyTestInitialize() { #region WebAii Initialization // Initializes WebAii manager to be used by the test case. // If a WebAii configuration section exists, settings will be // loaded from it. Otherwise, will create a default settings // object with system defaults. // // Note: We are passing in a delegate to the NUnit's TestContext.Out. // WriteLine() method. This way any logging // done from WebAii (i.e. Manager.Log.WriteLine()) is // automatically logged to same output as NUnit. // // If you do not care about unifying the log, then you can simply // initialize the test by calling Initialize() with no parameters; // that will cause the log location to be picked up from the config // file if it exists or will use the default system settings. // You can also use Initialize(LogLocation) to set a specific log // location for this test. // Pass in 'true' to recycle the browser between test methods Initialize(false, new TestContextWriteLine(Console.Out.WriteLine)); // If you need to override any other settings coming from the // config section or you don't have a config section, you can // comment the 'Initialize' line above and instead use the // following: /* // This will get a new Settings object. If a configuration // section exists, then settings from that section will be // loaded Settings settings = GetSettings(); // Override the settings you want. For example: settings.DefaultBrowser = BrowserType.FireFox; // Now call Initialize again with your updated settings object Initialize(settings, new TestContextWriteLine(Core.TestContext.Out.WriteLine)); */ #endregion // // Place any additional initialization here // } /// <summary> /// Clean up after each test. /// </summary> [TearDown] public void MyTestCleanUp() { // // Place any additional cleanup here // #region WebAii CleanUp // Shuts down WebAii manager and closes all browsers currently running this.CleanUp(); #endregion } /// <summary> /// Called after all tests in this class are executed. /// </summary> [TestFixtureTearDown] public void FixtureCleanup() { // This will shut down all browsers if // recycleBrowser is turned on. Else // will do nothing. ShutDown(); } #endregion [Test] public void SampleWebAiiTest() { // Launch a browser instance Manager.LaunchNewBrowser(BrowserType.Chrome); // 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: } [Test] [Description("My simple demo")] public void SimpleTest() { // Launch an instance of the browser Manager.LaunchNewBrowser(); // Navigate to google.com ActiveBrowser.NavigateTo("http://www.google.com"); // verify the title is actually Google. Assert.AreEqual("Google", ActiveBrowser.Find.ByTagIndex("title", 0).InnerText); } [Test] public void ComboBoxText() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo("http://demos.telerik.com/aspnet-ajax//ComboBox/Examples/Functionality/KeyboardSupport/DefaultCS.aspx"); RadComboBox combo = Find.ById<RadComboBox>("RadComboBox1"); Assert.AreEqual("New York", combo.Text); Assert.AreEqual(true, combo.Text.Contains("New")); Assert.AreEqual(false, combo.Text.Contains("Test")); } }}while (string.IsNullOrEmpty(uploadField.Value){ try { uploadField.Upload(path, 120000); } catch (TimeoutException) { Thread.Sleep(1000); }}[Test] [Description("Use HtmlControls drag/drop native support")] public void HtmlElementsDragDropSupport() { // Slow down the execution a bit so we can easily observe WebAii doing the drags<br> Manager.Settings.ExecutionDelay = 100; Manager.Settings.AnnotateExecution = true; ActiveBrowser.NavigateTo("http://developer.yahoo.com/yui/examples/dragdrop/dd-basic_clean.html");<br> // get the window element we are trying to drag. HtmlDiv div1 = Find.ById<HtmlDiv>("dd-demo-1"); HtmlDiv div2 = Find.ById<HtmlDiv>("dd-demo-2"); HtmlDiv div3 = Find.ById<HtmlDiv>("dd-demo-3"); //Move Div1 50 pixels to the right and 25 pixels to the top. div1.DragTo(50, -25); // Move Div2 to where Div3 is. div2.DragTo(div3); // Validate both locations are the same. Assert.AreEqual(div2.GetRectangle(), div3.GetRectangle()); }// Open the popup using mouse click so it doesn't hang execution.
Find.ByAttributes<HtmlInputButton>("type=button").MouseClick();ActiveBrowser.RefreshDomTree(); FramesCollection framesCollection = ActiveBrowser.Frames; int frameIndexWithSLApp = GetFrameIDwithSilverlightApp(framesCollection); SilverlightAppsList listOfSLApps = framesCollection[frameIndexWithSLApp].SilverlightApps(); SilverlightApp SLApp = listOfSLApps[0];
[Test]public void SampleWebAiiTest(){// Launch a browser instanceManager.LaunchNewBrowser(BrowserType.InternetExplorer);// The active browserActiveBrowser.NavigateTo("http://localhost/HTMLTestpage.htm");HtmlMainScreen homepage = new HtmlMainScreen(ActiveBrowser.Find);homepage.TextField1.Text = "Automation Test";homepage.OkButton.Click();Assert.AreEqual("Automation Test", homepage.Div1.InnerText, "Elements are not equal");}HtmlMainScreen attached.
The test pass but I get the following exception. I am runing Visual Studio 2010 on Windows 7 (64bit) and using jetbrains resharper 7.0 to run the unit test
System.Threading.ThreadAbortException
Thread was being aborted.
at
ArtOfTest.WebAii.Messaging.Process.BrowserRemoted.AsyncListenerThreadEntry() at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()