New to Telerik Test Studio? Start a free 30-day trial
Getting RadWindow Width and Height
You need to get the RadWindow width or height property.
Solution
First you need to get a reference to the RadWindow control by ID. Once you get it there are two options for getting the width/height. The first option is to use the relevant width/height properties of the RadWindow. The second is by invoking a straight JavaScript on the page.
Here is the standard approach:
C#
Manager.LaunchNewBrowser();
ActiveBrowser.NavigateTo("http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx");
Find.ById<HtmlInputSubmit>("Button3").MouseClick();
System.Threading.Thread.Sleep(1000);
ActiveBrowser.RefreshDomTree();
RadWindow window = Find.ById<RadWindow>("RadWindowWrapper_RadWindow_ContentTemplate");
//First Option
Assert.AreEqual(300, window.Width);Invoking JavaScript on the page:
C#
Manager.LaunchNewBrowser();
ActiveBrowser.NavigateTo("http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx");
Find.ById<HtmlInputSubmit>("Button3").MouseClick();
System.Threading.Thread.Sleep(1000);
ActiveBrowser.RefreshDomTree();
RadWindow window = Find.ById<RadWindow>("RadWindowWrapper_RadWindow_ContentTemplate");
//Second Option
string windowWidth = this.ActiveBrowser.Actions.InvokeScript(String.Format("$telerik.getBounds($find('RadWindow_ContentTemplate').get_popupElement()).width"));
Assert.AreEqual("300", windowWidth);