This is a migrated thread and some comments may be shown as answers.

Problems running framework samples

24 Answers 235 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wit
Top achievements
Rank 1
Wit asked on 23 Aug 2010, 11:58 AM
I can't successfully run some tests in the Samples. Here is example of one:

        [Test]
        [Description("Setting the text for a textbox or a textarea")]
        [Find("MyTextBox", "id=textbox1")]
        [Find("MyTextArea", "id=textarea1")]
        public void SetTextForAnElement()
        {
            // Now set the text for the text box
            Actions.SetText(this.Elements.GetHtml("MyTextBox"), "This is a TEST for TextBox!");

            // Now set the text for the text area.
            Actions.SetText(this.Elements.GetHtml("MyTextArea"), "This is a TEST for TextArea!");

            // DO ANY TEST VERIFICATION HERE

        }

The code compiles OK, but when I run it as unit test I get error:

System.ArgumentException : The FindParam key 'MyTextBox' is not found. Please make sure that they key is defined as part of the FindParamAttributes set on the test method or class - c:\WebAii\QuickStarts_NUnit_CS\Tests\BrowserActions.cs:187

Why doesn't it work.

I use SharpDevelop if it matters.

24 Answers, 1 is accepted

Sort by
0
Nikolai
Telerik team
answered on 24 Aug 2010, 11:24 AM
Hello Wit,

We never tried this SharpDevelop runner so just to clarify case:
1. Does IE opens
2. When IE opens do you have a NavigateTo page action
3. When the navigation is completed  the test method SetTextForAnElement() is being called and it fails

In the work flow above to which step you case ends?
Can you please also try running the test from VS's TestView. This works fine in our environment. 

Regards,
Nikolai
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Wit
Top achievements
Rank 1
answered on 24 Aug 2010, 12:27 PM
1. Yes. IE opens.
2. Page opened is: C:\WebAii\QuickStarts_NUnit_CS\Pages\BrowserActions.htm
3. SetTextForAnElement() is called and line Actions.SetText causes an error.

I read some more on old ArtOfTest forums and found that Find attributes are NUnit extensions to be downloaded and installed in nunit folder. However - links don't work any more.

I'll try installing Visual Studio Pro, but it guess it won't help.
0
Nikolai
Telerik team
answered on 24 Aug 2010, 12:48 PM
Hi Wit,

You are right. You are right that you don't need VS Pro to write your test but you will need both the upgrade and NUnit framework to open the samples projects.
You can find NUnit downloads here.


All the best,
Nikolai
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Wit
Top achievements
Rank 1
answered on 24 Aug 2010, 12:58 PM
Where can I find the WebAii extensions for NUnit mentioned here:
http://www.artoftest.com/support/webaii/topicsindex.aspx?topic=usingnunit ?

Do I need them if I install VS Pro?

0
Wit
Top achievements
Rank 1
answered on 24 Aug 2010, 02:00 PM
Finished installation of VS 2008 Pro Trial version. After that I reinstalled WebAii 2010.1 framework.
Started VS and got this:

Package 'Microsoft.VisualStudio.Xaml' has failed to load properly (GUID = {E58C2A8B-BCC4-4559-AD59-D6EB6D58A22}). Please contact package vendor for assistance. Application restart is recommended, due to possible environment corruption. Would you like to disable loading thi spackage in the future? You may use 'devenv /resetskippkgs' to re-enable package loading.

In File/New Project dialog I can only see standad Test template, no WebAii ones.

I opened sample project without problems and compiled it successfully. I started standalone Nunit and loaded the compiled assembly.
The test executed but failed exactly the same way as on SharpDevelop:

QuickStarts_NUnit_CS.BrowserActions.SetTextForAnElement:
System.ArgumentException : The FindParam key 'MyTextBox' is not found. Please make sure that they key is defined as part of the FindParamAttributes set on the test method or class

0
Nikolai
Telerik team
answered on 25 Aug 2010, 08:41 AM
Hi Wit,

Attached is the ArtOfTest.WebAii.NUnitExtension project. You can reference the NUnit framework dlls and build the project. I used NUnit ver. 2.5.1 and everything work fine. 
Another approach you can use is to set the test attributes manually like this:

[Test]
[Description("Setting the text for a textbox or a textarea")]
[Find("MyTextBox", "id=textbox1")]
[Find("MyTextArea", "id=textarea1")]
public void SetTextForAnElement()
{
    //Set Attributes
    base.SetTestMethod(this, "SetTextForAnElement");
 
    // Now set the text for the text box
    Actions.SetText(this.Elements.GetHtml("MyTextBox"), "This is a TEST for TextBox!");
 
    // Now set the text for the text area.
    Actions.SetText(this.Elements.GetHtml("MyTextArea"), "This is a TEST for TextArea!");
 
    // DO ANY TEST VERIFICATION HERE
 
}



Best wishes,
Nikolai
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Wit
Top achievements
Rank 1
answered on 25 Aug 2010, 10:07 AM
I use Nunit 2.5.7.

I updated references to use 2.5.7 and compiled the ArtOfTest.WebAii.NUnitExtension project . Then I put the dll in C:\Program Files\NUnit 2.5.7\bin\net-2.0\addins folder.

I started Nunit, selected Tools/Addins and there's no addins there.
Obviously SetTextForAnElement() test still has same error.

I then added line:
base.SetTestMethod(this, "SetTextForAnElement");

and eventually the test executed correctly.

So the questions still stand:
1. Why there is no WebAii templates visible in VS 2008 Pro?
2. Why the ArtOfTest.WebAii.NUnitExtensionaddin is not registered in NUnit?
3. Why the samples don't work by default and I have to add the call to base.SetTestMethod?

0
Nikolai
Telerik team
answered on 25 Aug 2010, 12:08 PM
Hello Wit,

1. Why there is no WebAii templates visible in VS 2008 Pro?
This is because the VS 2008 Pro does not support Testing only the VS 2008 Team System supports them. My deepest apologies for the mistake I saw the VS 2010 Pro specs instead of the VS 2008 Pro and the 2010 Pro supports testing.

2.Why the ArtOfTest.WebAii.NUnitExtensionaddin is not registered in NUnit?
I have compiled the ArtOfTest.WebAii.NUnitExtension project against NUnit ver. 2.5.7 and I see the dll in the add-ins section. May be if you updated the references manually this will fix the problem.

3.Why the samples don't work by default and I have to add the call to base.SetTestMethod?
Because the same code base is used both by the NUnit samples project and VSTS samples projects and this is not necessary for VSTS samples. We will consider adding that line in some of the next releases.


Regards,
Nikolai
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Wit
Top achievements
Rank 1
answered on 25 Aug 2010, 02:37 PM
1. I've just installed VS 2010 Pro Trial version and reinstalled WebAii framework. I can now see the WebAii classes.
However - there's no project template. So I end up using Class Library project template and modify the references e.g. adding references to NUnit.
Is that 'by design'?

2.  I changed compile configuration from Debug to Release and copied dll to nunit addins folder. Now I can see addin in Nunit. However trying to run SetTextForAnElement() test from within Nunit I get:

QuickStarts_NUnit_CS.BrowserActions.SetTextForAnElement:
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at ArtOfTest.WebAii.NUnitExtension.WebAiiTestMethod.RunTestMethod(TestResult testResult)
at NUnit.Core.TestMethod.doTestCase(TestResult testResult)
--NullReferenceException
at ArtOfTest.WebAii.TestTemplates.BaseTest.SetTestMethod(Object testObject, String testMethodName)


What's wrong?

0
Accepted
Nikolai
Telerik team
answered on 26 Aug 2010, 08:48 AM
Hello Wit,

 
There is no WebAii project template. You must create a standard VS Test project and  then from the Test Item Templates from the Add New Items menu add the WebAii test.

About the second problem. There seems to be a bug in the NUnit 2.5.7 runner. It does not reflect the "SetUp" attribute in the current test. This can be overcome by editing part of the WebAii.NUnitExtension:

#region NUnitTestMethod
 
    /// <summary>
    /// WebAii TestMethod class
    /// </summary>
    public class WebAiiTestMethod : TestMethod
    {
        /// <summary>
        /// Create a new TestMethod class.
        /// </summary>
        /// <param name="method">The test method info.</param>
        public WebAiiTestMethod(MethodInfo method)
            : base(method)
        {  }
 
        /// <summary>
        /// Intercept the RunTestMethod and perform loading of WebAii specific attributes.
        /// </summary>
        /// <param name="testResult">The testResult object</param>
        public override void RunTestMethod(TestResult testResult)
        {
            // Set the property
            object testFixture = this.Fixture;
             
            if (this.Fixture.GetType().BaseType.FullName.StartsWith("ArtOfTest.WebAii"))
            {
                var type = testFixture.GetType();
                type.InvokeMember("Initialize", BindingFlags.InvokeMethod, null, testFixture, null);               
 
                testFixture.GetType().InvokeMember("SetTestMethod", BindingFlags.InvokeMethod, null, testFixture
                    , new object[] { testFixture, testResult.Test.TestName.Name });
 
                type.InvokeMember("MyTestInitialize", BindingFlags.InvokeMethod, null, testFixture, null);               
            }
            base.RunTestMethod(testResult);
        }
    }
 
    #endregion

The change is only in the "RunTestMethod". You will have to add the change, rebuild and replace the add-in dll.

Hope this helps.

Greetings,
Nikolai
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Wit
Top achievements
Rank 1
answered on 26 Aug 2010, 10:30 AM
Now it works! Thank you.
0
Humberto
Top achievements
Rank 1
answered on 17 Apr 2013, 11:20 PM
Greetings,

I realize that the post is old but I am having the same problem as the Original Poster...or so I think.  

I've downloaded the attached ArtOfTest.WebAii.NUnitExtension project mentioned above.  I can't compile it though.  I've added the nunit.core and nunit.core.interfaces references to the project.  Mind you I am using NUnit 2.5.10.11092

I've also modified the method RunTestMethod as mentioned in the post but still I have two errors it seems.

One error (hover over tool tip) is with the override directive of the method saying 'There is no suitable method for override'

The other is at the base.RunTestMethod line saying that I cannot access a private method here.

So I'm at a bit of a loss.  Can you provide some guidance please.

-Humberto
0
Mario
Telerik team
answered on 23 Apr 2013, 04:13 PM
Hello Humberto,

From a higher level perspective of the issue, I suggest using our latest samples which come with your installation of the Telerik Testing Framework. By default, they are located in the path:
'C:\Program Files (x86)\Telerik\Test Studio\Samples\Testing Framework\'
With the benefit of being current, these samples would only require that you simply add the references you've mentioned to compile right out of the box.

If you've already considered this but have your own motives for using the old samples, please let us know in some additional detail what your end goal is so that we may better advise you.

Kind regards,
Mario
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Humberto
Top achievements
Rank 1
answered on 23 Apr 2013, 04:24 PM
I was/am trying to avoid using the latest version of Test Studio.  I found it had 1 very annoying bug that I didn't like. I think it has been resolved by now but I've not gotten around to upgrading again.

So you're saying the WebAii code samples are also updated as part of the Telerik Test Studio upgrade as well?
0
Mario
Telerik team
answered on 24 Apr 2013, 03:23 PM
Hi Humberto,

If you could let me know a PITS issue number or even just a general explanation of the nature of this bug you are referring to, I can find more details as far as when/if it was resolved.

Yes, there are occasional additions and changes made to these samples.

Kind regards,
Mario
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Humberto
Top achievements
Rank 1
answered on 24 Apr 2013, 03:37 PM
I can't.  But I will do the upgrade you suggest.  Maybe a reboot will help too.

Thank you Mario.
0
Humberto
Top achievements
Rank 1
answered on 24 Apr 2013, 04:23 PM
Sorry Mario,

No luck. I upgraded to TTS to 2012.2.1420.0.

Can you tell me what the latest version of TTS is?  I used the built in "Update" functionality in TTS and am told that it is up to date.  But I know I've not downloaded the installer recently.  Not in the last month for sure. So I am not certain.

However, I opened the "samples" project in Visual Studio...compiled the solution and it compiles fine. But when I try to run the UsingFindParamTestAttribute test it fails.

Error message:
QuickStarts_NUnit_CS.FindingElements.UsingFindFromFile:
System.IO.FileNotFoundException : Could not find file 'C:\Program Files (x86)\Telerik\Test Studio 2011.2\Samples\Testing Framework\QuickStarts_NUnit_CS\bin\Debug\FindElementsFromFile.xml'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Boolean detectEncodingFromByteOrderMarks)
at ArtOfTest.WebAii.Core.Find.FromExpressionsFile(String fileName)
at QuickStarts_NUnit_CS.FindingElements.UsingFindFromFile() in C:\Program Files (x86)\Telerik\Test Studio 2011.2\Samples\Testing Framework\QuickStarts_NUnit_CS\Tests\FindingElements.cs:line 516


So there same error remains...as the original poster had stated.

0
Mario
Telerik team
answered on 24 Apr 2013, 04:49 PM
Hi Humberto,

Please refer to the 'FindElementsFromFile' XML file in the following directory:

'C:\Program Files (x86)\Telerik\Test Studio\Samples\Testing Framework\QuickStarts_NUnit_CS\SupportFiles\'

You can copy and paste this example XML file into the following directory to rid yourself of the error:

''C:\Program Files (x86)\Telerik\Test Studio 2011.2\Samples\Testing Framework\QuickStarts_NUnit_CS\bin\Debug\'

Let me know if it helps.

Greetings,
Mario
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Humberto
Top achievements
Rank 1
answered on 24 Apr 2013, 05:07 PM
Sorry Mario, I think I posted the wrong "exception" message.  Your proposed solution makes sense for when using that external XML file that is not being found.  I'll confirm it once I try it out.

However, in reality 2 of the tests are failing, the 'UsingFindFromFile' test and the UsingFindParamTestAttribute test as well:

QuickStarts_NUnit_CS.FindingElements.UsingFindParamTestAttribute:
System.ArgumentException : The FindParam key 'MainTable' is not found. Please make sure that they key is defined as part of the FindParamAttributes set on the test method or class

at ArtOfTest.WebAii.Core.ElementFinder.GetElementLegacy(String key, Boolean waitOnElements, Int32 waitOnElementsTimeout)
at ArtOfTest.WebAii.Core.ElementFinder.GetHtml(String elementKey)
at QuickStarts_NUnit_CS.FindingElements.UsingFindParamTestAttribute() in C:\Program Files (x86)\Telerik\Test Studio 2011.2\Samples\Testing Framework\QuickStarts_NUnit_CS\Tests\FindingElements.cs:line 399

Thanks Mario.
0
Humberto
Top achievements
Rank 1
answered on 24 Apr 2013, 05:20 PM
Mario,

I did an source code file comparison between the 2011 "version" of the FindingElements.cs class and the 2012 "version" of the same class and they are identical.  So the source code hasn't changed at all.

So, upgrading really hasnt' done anything?

Am I back to having to use the ArtOfTest.WebAii.NUnitExtesion project and trying to compile it so I can use the resultant DLL in the "samples" project to get it to work correctly?

So my original post remains...why can't I compile the ArtOfTest.WebAii.NUnitExtension project, even after having made the modifications mentioned by Nikolai?  Are those applicable only that a very specific version of NUnit?
0
Mario
Telerik team
answered on 24 Apr 2013, 05:55 PM
Humberto,

I'm sorry but in my environment, after applying Nikolai's workaround, NUnit passes running the UsingFindParamTestAttribute sample test (I've tried various NUnit versions, including 2.5.10.11092): 

base.SetTestMethod(this, "UsingFindParamTestAttribute");
//Example 1:
Assert.IsTrue(this.Elements.GetHtml("MainTable").ElementType == ElementType.Table);
Assert.IsTrue(this.Elements.GetHtml("UpdateDate").ElementType == ElementType.Input);
 
//Example 2:
Assert.IsTrue(this.Elements.GetHtml("UpdateDate").ElementType == ElementType.Input);

You are correct, the FindingElements.cs class is the same, please excuse the inconvenience.

By the way to answer your previous question, 2012.2.1420 is the most recent 'official' release of Test Studio. However the most current would actually be the Latest Internal Build 2012.2.1527. You can set your upgrade settings to also check for internal builds from the 'Installation and Updates' tab of your Project Settings (see attached image).

Kind regards,
Mario
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Humberto
Top achievements
Rank 1
answered on 24 Apr 2013, 06:40 PM
Mario, I just did a copy and paste of the whole class as modified by Nikolai to ensure that it was identical and I hadn't mistyped something...and I still get the same warnings/errors,

'There is no suitable method for override'

and

Cannot access private method 'RunTestMethod' here

To be sure, there are only 3 modified lines of code that Nikolai described yes?
0
Humberto
Top achievements
Rank 1
answered on 24 Apr 2013, 06:47 PM
Mario,

What is that about? That extra line in your Unit Test

base.SetTestMethod(this,"UsingFindParamTestAttribute");

That is not in my Unit Test.

Once I add it and recompile the QuickStart samples source code, the Unit Test UsingFindParamTestAttribute is executed successfully by NUnit.

Please explain...I guess I missed that in Nikolai's explanation?
0
Cody
Telerik team
answered on 29 Apr 2013, 05:51 PM
Hi Humberto,

Mario is out of the office temporarily.

The base.SetTestMethod function tells Telerik Testing Framework which method to look at when looking for attributes to be used as input for finding elements. This method uses the attribute:

this.Elements.GetHtml("UpdateDate")

The attribute is specified above the method name like this:

[Test]
[Description("How to use [Find()] attributes on test class/method to define elements to use.")]
[Find("UpdateDate", "name=lastUpdate")]
public void UsingFindParamTestAttribute()
{

All the best,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Wit
Top achievements
Rank 1
Answers by
Nikolai
Telerik team
Wit
Top achievements
Rank 1
Humberto
Top achievements
Rank 1
Mario
Telerik team
Cody
Telerik team
Share this question
or