Telerik Forums
Testing Framework Forum
7 answers
922 views
Hi Guys,

Apologies for asking the same question again but I think I was not clear enough in the previous time: 
Using the WebAii Nunit template, I've got 2 separate CS. files. One file contains tests that call helper methods from the other. 

The file that contains the tests:

namespace MyTests
{
    [TestFixture]
    public class TestCase_Login : BaseTest
    {
        Paths Path = new Paths ();

        [Test]
        public void LoginBase()
        {
            Path.baseLogin(); 
        }
    }
}
The other file that contains the helper methods:

namespace Helpers
{
    class Paths : BaseTest
    {
        public void baseLogin()
        {
            Manager.LaunchNewBrowser(BrowserType.FireFox);
            Manager.SetNewBrowserTracking(true);
            ActiveBrowser.NavigateTo(Manager.Settings.BaseUrl);
            Manager.ActiveBrowser.WaitUntilReady();
        }
    }
}

Trying to run the test will result: 

System.NullReferenceException: Object reference not set to an instance of an object.


I understand that there is no testsetup run for the Paths class so the inherited BaseTest Manager objectis not instantiated and is not settable to the outer class' Manager referencesince the BaseTest Manager reference is read only.


As I want to keep the helper methods in a separate cs. file, could please advice how should I create a private manager property for 

the Paths class (And similar classes) and how to pass the outer class manager in the constructor in order to be able to use a single instantiated Manager object to be used in the different helper classes. 

 


Thanks in advance, 

SD. 









SD
Top achievements
Rank 1
 answered on 14 May 2010
3 answers
271 views

I need to write a step with conditional logic. According to the user guide, this requires a code-behind method. I'm having a problem handling a confirmation dialog within the code-behind method: the dialog does not get dismissed, and the test fails with a timeout.

I have a pure WebAii test that handles the same confirmation successfully, so I generated a unit test from that and copied the dialog manager code you see below. Is this the wrong technique for use in a code-behind?

        [CodedStep(@"Delete customer record if it exists")]  
        public void DeleteCustomerIfExists()  
        {  
            string emailAddress = "abc@xyz.com";  
 
            Pages.CustomerSearch.SearchFor.Text = emailAddress;  
            Pages.CustomerSearch.SearchButton.Click(false);  
 
            HtmlAnchor customerLink = Find.ByAttributes<HtmlAnchor>("title=" + emailAddress);  
            if (customerLink != null)  
            {  
                // Handle 'Confirm' dialog.  
                ConfirmDialog confirmDialog = new ConfirmDialog(ActiveBrowser, DialogButton.OK);  
                Manager.DialogMonitor.AddDialog(confirmDialog);  
 
                // this displays confirmation dialog  
                Pages.CustomerSearch.DeleteCustomerButton.Click(false);  
 
                confirmDialog.WaitUntilHandled(5000);  
            }  
        } 

Thanks!

Missing User
 answered on 13 May 2010
1 answer
121 views
I created the little helper function below to confirm that a SL4 datagrid loads.  Im getting inconsistent results attempting to run this function on the same grid.  Basically sometimes it works sometimes not.  Is there issues in the framework around this?  Also if i actual break in vs2010 after the 'g' variable is set, and then try to put "?g" into the immediate window IE8 bombs.

Any thoughts?


        public static void VerifyGridLoaded(SilverlightApp app, string gridName)
        {

            DataGrid g = app.FindName<DataGrid>(gridName);
            g.Refresh();
            Assert.IsTrue(g.Rows.Count() > 0, gridName + " is empty.");
        }

Missing User
 answered on 12 May 2010
2 answers
215 views
Could you provide an updated link to - http://www.artoftest.com/Downloads/Support/vs_piaredist.exe

Thx.
Rob Lange
Top achievements
Rank 1
 answered on 07 May 2010
7 answers
433 views

Hello!
I am new in WebAii and, to be honest, I am new in C# programming.


I try creating my own project or using a sampler (SilverlightHealthcareSample.cs). I have an error with message:

 

Test method QuickStarts_VSTS_CS.SilverlightHealthcareSample.HealthCareDemo threw exception:  System.NullReferenceException: Object reference not set to an instance of an object..

 

at ArtOfTest.Common.TreeCrawler`3.SearchUsingNonHierarchialMatch(ITargetElement startNode, IList`1 clauses, V expression, Boolean ignoreConstraints)

at ArtOfTest.Common.TreeCrawler`3.Find(T startNode, IList`1 clauses, V expression, Boolean includeRoot, Boolean ignoreContraints)

at ArtOfTest.Common.TreeCrawler`3.ByExpression(T startNode, V expression, Boolean includeRoot)

at ArtOfTest.Common.TreeCrawler`3.ByExpression(V expression)

at ArtOfTest.WebAii.Silverlight.VisualFind.ByName(String name)

at ArtOfTest.WebAii.Silverlight.SilverlightApp.FindName(String name)

at QuickStarts_VSTS_CS.SilverlightHealthcareSample.HealthCareDemo() in C:\..\UnitTest1.cs:line 155

 

Error is occurred when I try to use any Find method.

 

My code (only interesting lines, actually it is all from the sampler):

 

[TestInitialize()]

public void MyTestInitialize()

{

Settings settings = GetSettings();

settings.EnableSilverlight = true;

Initialize(settings, new TestContextWriteLine(this.TestContext.WriteLine));

SetTestMethod(this, (string)TestContext.Properties["TestName"]);

}

 

[TestMethod]

[Description("Automate a complex Silverlight application")]

public void HealthCareDemo()

{

Manager.Settings.ExecutionDelay = 10;

Manager.LaunchNewBrowser(BrowserType.InternetExplorer);

System.Drawing.Point loc = ActiveBrowser.Window.Location;

ActiveBrowser.NavigateTo("http://www.mscui.net/PatientJourneyDemonstrator/PrimaryCareAdmin.htm");

ActiveBrowser.Window.Move(new System.Drawing.Rectangle(loc, new System.Drawing.Size(1024, 768)), true);

 

//SilverlightApp app = ActiveBrowser.SilverlightApps()[0];

// I have an error on the line above, but with line below works fine

SilverlightApp app = ActiveBrowser.SilverlightApps().First();

 

app.FindName("guideButton").User.Click(); // <= I have the error there

}

 

Also I tried to use construction like this:

            TextBox name1 = app.Find.ByName<TextBox>("name1");

            FrameworkElement ss = app.Find.ByName("name1");


I have the same error.

 

I tried to run that code with the latest version of WebAii 2.0 from ArtOfTest site. After that I uninstalled WebAii and installed WebAii (Testing Framework 2010.1.412.FREE_EDITION) from Telerik site. But the error is still present.

 

Could you please give me an advice to solve the issue? May be something wrong with my environment?

 

MS Win XP Professional SP 3 English

Visual Studio 2008

IE 8.0.6001.18702

MS Silverlight 3.0.50106.0 (add-ons is enabled in IE)

WebAii Test Execution Extension 2.0.50727.3053 (add-ons is enabled in IE)

Thanks for your attention.

Cody
Telerik team
 answered on 07 May 2010
1 answer
152 views
Can we perform performance testing with this framework?
Cody
Telerik team
 answered on 29 Apr 2010
1 answer
137 views

In one of the threads before I read that we can't have two manager objects as I noticed when getting all pipe busy message. What is the suggested way in creating X number of browser sessions and navigating them indipendently?

This didn't work for me:

 

 

Manager.LaunchNewBrowser(BrowserType.InternetExplorer, true);
Manager.LaunchNewBrowser(BrowserType.InternetExplorer, true); 

 

 

...
...
int numberOfBrowsers = Manager.Browsers.Count; //shows correct number of browser sessions
Manager.Browsers[0].Window.Show();
Manager.Browsers[0].Window.SetActive();

//how to find an element in silverlight page that is on the list
Pages.PageName.MyButton.Click(false);
Manager.ActiveBrowser.Window.Minimize();

Manager.Browsers[1].Window.Show();
Manager.Browsers[1].Window.SetActive();
Pages.PageName.MyButton.Click(false); //problem with this - it can't find this element to click on

...
...

Any Ideas? Thanks.

Cody
Telerik team
 answered on 29 Apr 2010
5 answers
144 views
I have a VS unit test that needs to alter the value of Settings.ExecuteCommandTimeout before doing a Get<>. I'm updating the Settings via the following code:

ActiveBrowser.Manager.Settings.ExecuteCommandTimeout = 8888;

When I initially created the Manager object I used a Settings object that set the ExecuteCommandTimeout property to 4444. So 4444 is the background setting and my override is 8888.

For testing's sake I'm using the following code in my unit test to verify that my Setting.ExecuteCommandTimeout is not being used:

resultControl = Get<HtmlControl>(new HtmlFindExpression("TextContent=" + textContent), false, 1000);
// check value of resultControl.Wait.Timeout in debugger
resultControl.Wait.ForExists(); // this line takes ~4444ms

If just before this code I check in the debugger the following:

ActiveBrowser.Manager.Settings.ExecuteCommandTimeout
ActiveBrowser.Frames[<all>].Manager.Settings.ExecuteCommandTimeout

where <all> are all the frames in my Frames collection, I see that the ExecuteCommandTimeout is 8888!

So my question is what am I missing to get the Get<> methods to honour the new timeout value?

Thanks in advance,
Matt


macon
Top achievements
Rank 1
 answered on 29 Apr 2010
2 answers
195 views
Hello All,

I'm new to WebAii framework and I've got a question about the Wait class.

I have a scenario where I need to locate a table cell (td). I'm going to locate it by content but the content might be contained directly inside the cell or it might be the content of a child element of the table cell (e.g. a span).

I'm using:
Get<WebAiiHtmlControls.HtmlTableCell>("TextContent=" + textContent, "tagname=td");

The problem is that it times out and raises a System.TimeoutException (because in this instance the text is contained deeper inside a span). In this scenario I just want it to timeout and the Get() method to return null. Is this possible? I don't really want to insert try/catch into my code.

Thanks,
Matt
macon
Top achievements
Rank 1
 answered on 27 Apr 2010
4 answers
209 views
I have been trying to get the WebAii Rad AJAX Control Wrapper to work for RadListView with limited success.  About to give up in frustration, I decided to run the sample application, the test for RadListView in the sample application failed on all test cases.

I am using Telerik WebAii Testing Framework 2010.1 (Version 101.4.12.0) and Telerik RadControls for ASP.NET AJAX Q1 2010 (10.1.3.9).

When my RadToolbar before the RadListView is visible, my finds seem to always fail.

        <telerik:RadAjaxPanel ID="AjaxPanel" 
                              runat="server" 
                              LoadingPanelID="AjaxLoadingPanel" 
                              ClientEvents-OnResponseEnd="ajaxResponseEnd" 
                              ClientEvents-OnRequestStart="ajaxRequestStart"
            <telerik:RadToolBar ID="SuperUser" 
                                runat="server" 
                                Width="100%" 
                                Visible="false"
                <Items> 
                    <telerik:RadToolBarDropDown Text="Information" 
                                                ID="InformationButton" 
                                                runat="server" 
                                                Visible="false"
                        <Buttons> 
                            <telerik:RadToolBarButton runat="server" 
                                                      ID="GpDatabase" 
                                                      Enabled="false" /> 
                                                       
                            <telerik:RadToolBarButton runat="server" 
                                                      ID="GpCompanyId" 
                                                      Enabled="false" /> 
                                                       
                            <telerik:RadToolBarButton runat="server" 
                                                      ID="TransFirstMode" 
                                                      Enabled="false" /> 
                                                       
                            <telerik:RadToolBarButton runat="server" 
                                                      ID="DatabaseServer" 
                                                      Enabled="false" /> 
                        </Buttons> 
                    </telerik:RadToolBarDropDown> 
                     
                    <telerik:RadToolBarButton ID="SalesRep" 
                                              runat="server" 
                                              Visible="false"
                        <ItemTemplate><img src="~/img/user_go.png" runat="server" style="vertical-align: middle;" /> Select Sales Rep: </ItemTemplate> 
                    </telerik:RadToolBarButton> 
                                                 
                    <telerik:RadToolBarButton ID="OriginalOwner" 
                                              runat="server" 
                                              Group="SalesReps" 
                                              CheckOnClick="true" 
                                              Checked="true" 
                                              ImageUrl="~/img/user_gray.png" 
                                              Visible="false" /> 
                     
                    <telerik:RadToolBarButton ID="CurrentRep" 
                                              runat="server" 
                                              Group="SalesReps" 
                                              CheckOnClick="true" 
                                              ImageUrl="~/img/user_edit.png" 
                                              Visible="false" /> 
                </Items> 
            </telerik:RadToolBar> 
            <telerik:RadListView ID="Projects" 
                                 runat="server" 
                                 ItemPlaceHolderID="ProjectHolder" 
                                 AllowPaging="true" 
                                 AllowCustomPaging="true" 
                                 PageSize="6"
                <LayoutTemplate> 
                    <div  class="RadListView RadListViewFloated RadListView_<%# Container.Skin %>"
                    <table style="margin: auto;" class="layout" cellspacing="0"
                        <tr> 
                            <td rowspan="5" style="background-repeat: repeat-y; background-image: url(img/border-left.png); background-position: right; width: 25px; padding: 0px;">&nbsp;</td> 
                            <td colspan="2"
                                <img src="img/ae_checkout.png" alt="Account Executive Checkout Logo" /> 
                            </td> 
                            <td rowspan="5" style="background-repeat: repeat-y; background-image: url(img/border-right.png); background-position: right; width: 25px; padding: 0px;">&nbsp;</td> 
                        </tr> 
                        <tr>                             
                            <td colspan="2"
                                <co:Navigator ID="QuickNavigator" runat="server" /> 
                            </td> 
                        </tr> 
                        <tr> 
                            <td style="vertical-align: text-top;"
                                <asp:PlaceHolder ID="ProjectHolder" runat="server" /> 
                            </td> 
                            <td style="vertical-align: text-top; white-space: nowrap;"
                                <telerik:RadPanelBar ID="SalesItems" 
                                                     runat="server" 
                                                     Width="370px" 
                                                      
                                                     CssClass="invoice"
                                    <Items> 
                                        <telerik:RadPanelItem Text="Sales Items"
                                            <ItemTemplate> 
                                                <table cellpadding="0" cellspacing="0" style="width: 100%"
                                                    <tr> 
                                                        <td> 
                                                            <co:Invoice ID="SalesInvoice" runat="server" AllowRemoval="true" /> 
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="background-color: #8EA3B9; padding-left: 5px;"
                                                            <telerik:RadNumericTextBox ID="Discount" 
                                                                                       runat="server" 
                                                                                       Type="Currency" 
                                                                                       Label="Discount: " 
                                                                                       Value="0" 
                                                                                       EnabledStyle-HorizontalAlign="Right" 
                                                                                        /> 
                                                            <asp:ImageButton ID="ApplyDiscountButton" 
                                                                             runat="server" 
                                                                             ImageUrl="~/img/arrow_refresh.png" 
                                                                             OnClick="ApplyDiscountButton_Click" /> 
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="text-align: right; background-color: #8EA3B9;"
                                                            <asp:Button ID="ClearButton" runat="server" Text="Clear" OnClick="ClearButton_Click"/> 
                                                            <asp:Button ID="EstimateButton" runat="server" Text="Create Quote" OnClick="CreateEstimateButton_Click" /> 
                                                            <asp:Button ID="BillMeButton" runat="server" Text="Bill Me" OnClick="BillMeButton_Click" /> 
                                                            <asp:Button ID="CheckOutButton" runat="server" Text="Pay Now" OnClick="CheckOutButton_Click" />                                                             
                                                        </td> 
                                                    </tr> 
                                                </table> 
                                            </ItemTemplate> 
                                        </telerik:RadPanelItem> 
                                    </Items> 
                                </telerik:RadPanelBar> 
                            </td> 
                        </tr> 
                        <tr> 
                            <td style="vertical-align: text-top" colspan="2"
                                <telerik:RadDataPager ID="DataPager" 
                                                      runat="server" 
                                                      PageSize="6" 
                                                      PagedControlID="Projects"
                                    <Fields> 
                                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" /> 
                                        <telerik:RadDataPagerButtonField FieldType="Numeric" /> 
                                        <telerik:RadDataPagerButtonField FieldType="NextLast" /> 
                                        <telerik:RadDataPagerPageSizeField PageSizeText="Projects per Page: " /> 
                                        <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go" /> 
                                        <telerik:RadDataPagerTemplatePageField> 
                                        <PagerTemplate> 
                                            <div style="float: right"
                                                <b>Projects 
                                                    <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" /> 
                                                    to 
                                                    <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# IIf(Container.Owner.StartRowIndex+Container.Owner.PageSize > Container.Owner.TotalRowCount, Container.Owner.TotalRowCount, Container.Owner.StartRowIndex+Container.Owner.PageSize) %>" /> 
                                                    of 
                                                    <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount %>" /> 
                                                    <br /> 
                                                </b> 
                                            </div> 
                                        </PagerTemplate> 
                                    </telerik:RadDataPagerTemplatePageField> 
                                    </Fields> 
                                </telerik:RadDataPager>                                 
                            </td> 
                        </tr> 
                    </table>        
                    </div>  
                </LayoutTemplate> 
                <ItemTemplate> 
                    <asp:HiddenField ID="ProjectName" runat="server" Value='<%#Eval("ProjectAbbreviation") %>' /> 
                    <telerik:RadPanelBar ID="ProjectPanelBar" 
                                         runat="server" 
                                         Width="619px" 
                                         CssClass='<%#IIf(Eval("ProjectAbbreviation").ToString().Equals(Account.DefaultProject, StringComparison.CurrentCultureIgnoreCase), "highlightedProject projectHolder", "projectHolder") %>'
                        <Items> 
                            <telerik:RadPanelItem Text="Project Name" 
                                                  runat="server" 
                                                  ClickedCssClass="rpOut" 
                                                  ExpandedCssClass="rpOut" 
                                                  FocusedCssClass="rpOut" 
                                                  SelectedCssClass="rpOut"
                                <ItemTemplate>      
                                    <co:Project ID="Project" runat="server" />                     
                                </ItemTemplate> 
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelBar> 
                     
                </ItemTemplate>                             
                <EmptyDataTemplate> 
                    <span style="width: 619px; text-align: center;"
                        <h1>No projects available for this account.</h1> 
                    </span> 
                </EmptyDataTemplate>                 
            </telerik:RadListView> 
        </telerik:RadAjaxPanel>   

Test Framework Code:
        Dim ajaxPanelPanel As HtmlDiv = Find.ById(Of HtmlDiv)("AjaxPanelPanel"
 
        Assert.IsNotNull(ajaxPanelPanel) 
 
        Dim ajaxPanel As HtmlDiv = Find.ById(Of HtmlDiv)("AjaxPanel"
 
        Assert.IsNotNull(ajaxPanel) 
 
        'Dim element_ As ArtOfTest.WebAii.ObjectModel.Element = ajaxPanel.Find.ById("Projects") 
        'Dim listView As RadListView = element_.As(Of RadListView)() 
        Dim listView As RadListView = ajaxPanel.Find.ByAttributes(Of RadListView)("class=RadListView RadListViewFloated RadListView_Default"

I can find the div and use an As(Of RadListView)(), but it throws an exception about the span should of been an input.  I recently upgraded to the latest version (above) to see if it would resolve some of these issues but no luck.
Konstantin Petkov
Telerik team
 answered on 27 Apr 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?