The default behavior of Test Studio and the Telerik Testing Framework is to time out after a certain interval if the element is not found.
I would like to avoid the Timeout Exception and perform a different set of steps depending on whether the element is found. My application does not use silverlight.
I have checked the Telerik help document , Change Silverlight Find Strategy, but i think it is applicable for only Silverlight applications.
Below is the code snippet which i want to perform if the 'MS2007AboveRadio' check box on the iframe is found. To avoid Timedout Exception if the element is not found, i have placed it in the try catch block. Tried the if else condition aswelll, but it gets timedout.
try{ Pages.application.FrameFrame1.MS2007AboveRadio.Check(true, true); Pages.application.FrameFrame1.CphMainBtnProceedImage.Click(true); } catch{ }foreach (RadMenuItem rootitem in menu.RootItems) { string menuHeader = rootitem.Text; Log.WriteLine("The menu header is - " + menuHeader); RadMenuItem menuList = menu.FindItemByText(menuHeader); foreach (RadMenuItem childitem in menuList.Items) { string chldItem = childitem.Text; Log.WriteLine(menuHeader + " - " + chldItem); if (childitem.HasChildren) { int c = childitem.ChildNodes.Count; for (int i = 1; i <= c; i++) { string childChild = ****CAN'T FIGURE THIS CODE OUT**** Log.WriteLine(menuHeader + " - " + chldItem + " - " + childChild); } } } }using System;using System.Text;using System.Collections.Generic;using System.Linq;using Microsoft.VisualStudio.TestTools.UnitTesting;using ArtOfTest.WebAii.Core;using ArtOfTest.WebAii.TestTemplates;using ArtOfTest.WebAii.Extensions;using ArtOfTest.WebAii.Silverlight;using ArtOfTest.WebAii.Silverlight.UI;using ArtOfTest.WebAii.Silverlight.Attributes;using ArtOfTest.Common;using ArtOfTest.WebAii.Controls.Xaml;using ArtOfTest.WebAii.Controls.HtmlControls;namespace TestProject7{ [TestClass] public class UnitTest1 { public UnitTest1() {
} private TestContext testContextInstance; public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } [TestMethod] public void TestMethod1() { Settings mySettings = new Settings(); mySettings.Web.DefaultBrowser = BrowserType.Chrome; mySettings.ClientReadyTimeout = 120000; Manager myManager = new Manager(mySettings); //must start myManager after creating it myManager.Start(); try { Settings.Current.Web.EnableSilverlight = true; mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle; myManager.LaunchNewBrowser(); myManager.ActiveBrowser.NavigateTo("http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html"); myManager.ActiveBrowser.WaitUntilReady(); SilverlightAppsList apps = myManager.ActiveBrowser.SilverlightApps(); SilverlightApp app = apps.ToArray()[0]; string ok = "I am glad if this is executed :)"; } catch (Exception e) { myManager.Dispose(); } } }}Hello.
i run my tests with jenkins configured building and running tests on remote computer.
tests all ok but each test throw exception
Internal error: An unhandled exception occurred. The exception occurred while test step 'test10' was running. System.Threading.ThreadAbortException: Thread was being aborted. at ArtOfTest.WebAii.Messaging.Process.BrowserRemoted.AsyncListenerThreadEntry() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) 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() |