34 Answers, 1 is accepted
Thanks for the post and question. So there really isn't a way to do what you describe using a built in feature in either QA or Dev edition.
I'll log a feature request for this, but there are custom coded solutions we could offer in Dev Edition depending upon what browser(s) you would need this to run in and if you wanted to use a coded solution.
Please reply back how you would like to proceed.
Quick Edit: Sorry, forgot to mention the custom code solution should also work in QA edition. Please reply back if you'd like to continue working in code for this.
Kind regards,
Nelson Sin
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.
So for the QA edition, please:
1) Extract the attached dll to the bin folder of your WebUI Test Project
2) Add the dll as a reference to your test project in the UserSettings -> Script Options (See attached screentshot)
3) Add a 'Script Step' to your test that will execute first.
4) Click Class View and copy the following code.
using
System;
using
System.Collections.Generic;
using
System.Text;
using
ArtOfTest.Common.UnitTesting;
using
ArtOfTest.WebAii.Core;
using
ArtOfTest.WebAii.Controls.HtmlControls;
using
ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
using
ArtOfTest.WebAii.Design;
using
ArtOfTest.WebAii.Design.Execution;
using
ArtOfTest.WebAii.ObjectModel;
using
ArtOfTest.WebAii.Silverlight;
using
ArtOfTest.WebAii.Silverlight.UI;
using
Telerik.WebAii.Controls.Html;
using
Telerik.WebAii.Controls.Xaml;
using
ArtOfTest.WebAii.Win32.Dialogs;
namespace
CustomHandlerQA
{
//
// You can add custom execution steps by simply
// adding a void function and decorating it with the [CodedStep]
// attribute to the test method.
// Those steps will automatically show up in the test steps on save.
//
// The BaseWebAiiTest exposes all key objects that you can use
// to access the current testcase context. [i.e. ActiveBrowser, Find ..etc]
//
// Data driven tests can use the Data[columnIndex] or Data["columnName"]
// to access data for a specific data iteration.
//
// Example:
//
// [CodedStep("MyCustom Step Description")]
// public void MyCustomStep()
// {
// // Custom code goes here
// ActiveBrowser.NavigateTo("http://www.google.com");
//
// // Or
// ActiveBrowser.NavigateTo(Data["url"]);
// }
//
public
class
New_Test : BaseWebAiiTest
{
#region [ Dynamic Pages Reference ]
private
Pages _pages;
/// <summary>
/// Gets the Pages object that has references
/// to all the elements, frames or regions
/// in this project.
/// </summary>
public
Pages Pages
{
get
{
if
(_pages ==
null
)
{
_pages =
new
Pages(Manager.Current);
}
return
_pages;
}
}
#endregion
// Add your test methods here...
[CodedStep(@
"Custom Confirm Handler Step'"
)]
public
void
WebAiiTest1_CodedStep()
{
Manager.DialogMonitor.Dialogs[0].HandlerDelegate = CustomConfirm;
}
void
CustomConfirm(IDialog dialog)
{
Log.WriteLine(TelerikCustomHandler.HandleClass.HandleDialog(dialog.Window.Handle));
dialog.HandlerDelegate =
null
;
}
}
}
Please note the
Log.WriteLine(TelerikCustomHandler.HandleClass.HandleDialog(dialog.Window.Handle));
is where the Dialog Text is returned, here it's being written to the test results log file. Also, the
Manager.DialogMonitor.Dialogs[0] assumes the Dialog Handler you want to retrieve text from is the first one you added/recorded to the test
. The index is 0 based, so please adjust this to the dialog handler you want to retrieve the text from.Please reply back if you have any questions on the above.
Kind regards,
Nelson
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.
--------------------------------------------------
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 1.aii.cs: Line 5: (CS0234) The type or namespace name 'UnitTesting' does not exist in the namespace 'ArtOfTest.Common' (are you missing an assembly reference?)
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 1.aii.cs: Line 14: (CS0246) The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 1.aii.cs: Line 15: (CS0246) The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 2.aii.cs: Line 1: (CS0246) The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 2.aii.cs: Line 2: (CS0246) The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 1.aii.cs: Line 51: (CS0246) The type or namespace name 'Pages' could not be found (are you missing a using directive or an assembly reference?)
c:\Users\sdavis\Documents\WebUI Test Studio Projects\TestProject1\Sam Test 1.aii.cs: Line 58: (CS0246) The type or namespace name 'Pages' could not be found (are you missing a using directive or an assembly reference?)
When I click on Class view, do I replace the code that is in the class with what you sent me? I still get the same error when I do that. When I remove the added script step, it still keeps failing with the failed compilation message.
Sorry about the late reply. Please check out the attached screenshot on how to check for and add dll references to you test project. Also, please note the versions of the following references of the ArtOfTest and Telerik dlls and verify they are 2010.1.5.18:
ArtOfTest.Common
ArtOfTest.WebAii
ArtOfTest.WebAii.Design
Telerik.WebAii.Controls.Html
Telerik.WebAii.Controls.Xaml
But regardless of whether the references are there and the version numbers, please try removing all of the ArtOfTest and Telerik references using the red 'X' button. Then, use the Add Reference button and re-add them from the following installation locations:
\Program Files\Telerik\WebUI Test Studio 2010.1\Bin
\Program Files\Telerik\WebUI Test Studio 2010.1\Bin\Translators
If re-adding the references does not work, if you can please attach and send us the entire test project for us to check out on this end.
Sincerely,
Nelson
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.
Thanks, I got it to work now.
Yes you can use the same DLL in both versions. In terms of recording and runnign tests the feature set between the QA edition and the Dev edition is virtually identical. The key difference is that QA edition has its own standalone IDE whereas the Dev edition is a plug-in to Visual Studio. Beyond that whatever can be done in one edition you should have no problems doing in the other. They even share most of the same source code base.
Greetings,
Cody
the Telerik team
thanks.
I am sorry but I don't understand what "script options" you are referring to. Can you elaborate? Are you running into a problem? What error do you get?
Best wishes,Cody
Hello again Sam,
So for the QA edition, please:
1) Extract the attached dll to the bin folder of your WebUI Test Project
2) Add the dll as a reference to your test project in the UserSettings -> Script Options (See attached screentshot)
3) Add a 'Script Step' to your test that will execute first.
4) Click Class View and copy the following code.
I cannot execute #2 above because in my software, the UserSettings -> Script Options is disabled. I would like to know how to enable this option so that I can follow the rest of the instructions. I am using Telerik thru Visual Studio.
Thanks,
Mike
The Script Options is simply not needed in Visual Studio where you can add any needed assembly reference from the Visual Studio's Solution Explorer. Does that help?
Sincerely yours,
Konstantin Petkov
the Telerik team
Thanks for your help,
Mike
You can add script step as in the QA Edition then add the sample code to the test step method you will get in the .cs file.
Please let us know if you need further assistance.
Regards,
Konstantin Petkov
the Telerik team
Here is the same source code converted to VB.NET. Is that sufficient?
Imports
System.Collections.Generic
Imports
System.Text
Imports
ArtOfTest.Common.UnitTesting
Imports
ArtOfTest.WebAii.Core
Imports
ArtOfTest.WebAii.Controls.HtmlControls
Imports
ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts
Imports
ArtOfTest.WebAii.Design
Imports
ArtOfTest.WebAii.Design.Execution
Imports
ArtOfTest.WebAii.ObjectModel
Imports
ArtOfTest.WebAii.Silverlight
Imports
ArtOfTest.WebAii.Silverlight.UI
Imports
Telerik.WebAii.Controls.Html
Imports
Telerik.WebAii.Controls.Xaml
Imports
ArtOfTest.WebAii.Win32.Dialogs
Namespace
CustomHandlerQA
'
' You can add custom execution steps by simply
' adding a void function and decorating it with the [CodedStep]
' attribute to the test method.
' Those steps will automatically show up in the test steps on save.
'
' The BaseWebAiiTest exposes all key objects that you can use
' to access the current testcase context. [i.e. ActiveBrowser, Find ..etc]
'
' Data driven tests can use the Data[columnIndex] or Data["columnName"]
' to access data for a specific data iteration.
'
' Example:
'
' [CodedStep("MyCustom Step Description")]
' public void MyCustomStep()
' {
' // Custom code goes here
' ActiveBrowser.NavigateTo("http://www.google.com");
'
' // Or
' ActiveBrowser.NavigateTo(Data["url"]);
' }
'
Public
Class
New_Test
Inherits
BaseWebAiiTest
#Region "[ Dynamic Pages Reference ]"
Private
_pages
As
Pages
''' <summary>
''' Gets the Pages object that has references
''' to all the elements, frames or regions
''' in this project.
''' </summary>
Public
ReadOnly
Property
Pages()
As
Pages
Get
If
_pages
Is
Nothing
Then
_pages =
New
Pages(Manager.Current)
End
If
Return
_pages
End
Get
End
Property
#End Region
' Add your test methods here...
<CodedStep(
"Custom Confirm Handler Step'"
)> _
Public
Sub
WebAiiTest1_CodedStep()
Manager.DialogMonitor.Dialogs(0).HandlerDelegate =
AddressOf
CustomConfirm
End
Sub
Private
Sub
CustomConfirm(dialog
As
IDialog)
Log.WriteLine(TelerikCustomHandler.HandleClass.HandleDialog(dialog.Window.Handle))
dialog.HandlerDelegate =
Nothing
End
Sub
End
Class
End
Namespace
Cody
Timed out waiting '5000' msec. for dialog to be handled '1'
InnerException:
System.TimeoutException: Timed out waiting '5000' msec. for dialog to be handled '1'
at ArtOfTest.WebAii.Win32.Dialogs.BaseDialog.WaitUntilHandled(Int32 handleCount, Int32 timeout, Boolean resetHandleCount)
at ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors.DialogHandlerDescriptor.Execute(Browser browser)
at ArtOfTest.WebAii.Design.IntrinsicTranslators.Descriptors.DialogHandlerDescriptor.Execute(IAutomationHost browser)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteStep()
--------------------------------------------------
Thanks for all your help on this whole thread.
Mike
Is this feature included in the latest version of test studio?
Thanks
Is this feature included in the latest version of test studio?
Thanks
Is this feature included in the latest version of test studio?
Thanks
Is this feature now included in the latest version?
Do you mean is it now possible to verify/extract text from a JavaScript Alert dialog without code through the UI? If so then the answer is no. The coded solution provided in this thread is a great work-around, however.
Regards,
Anthony
the Telerik team
Have you looked at the new Online User Guide for Telerik Test Studio?
Using the code posted in vs.net, what i am doing is throwing a application exception in the CustomConfirm method, however when the exception is fired it does not record it as an exception an fail the test as expected insted it gives the test result as Passed.
here is the snippet
public void SaveForm(string entityName_)
{
ActiveBrowser.RefreshDomTree();
DialogMonitor.Start();
DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(Manager.ActiveBrowser, DialogButton.OK));
DialogMonitor.Dialogs[1].HandlerDelegate = CatchMessage;
var saveButton = Manager.ActiveBrowser.Find.ById<HtmlAnchor>("Save");
saveButton.Focus();
saveButton.MouseClick(MouseClickType.LeftClick);
UnexpectedDialogAction action = UnexpectedDialogAction.DoNotHandle;
}
void CatchMessage(IDialog dialog)
{
try
{
alertmessage = dialog.Window.AllChildren[2].Caption;
HandleClass.HandleDialog(dialog.Window.Handle);
dialog.Window.Close();
throw new ApplicationException(string.Format("The test script cannot be executed because of the error {0}", alertmessage));
}
catch (Exception exception)
{
throw exception;
}
}
Adding to the above, i even tried to access variable /method and assign it the alertmessage value,however it does not work
Also it is observed that the handler call is not consistant, it sometimes works but sometimes never hits the handler even tough dialog count is 2
Any help appriciated
Thanks
A throw within the sub-thread will be ignored by the main testing thread. You will need to move that code to the main thread for it to work.
Why are you trying to unconditionally throw an exception and fail the test? Please provide more information on your scenario so we can better troubleshoot it.
Anthony
the Telerik team
That DLL is built using .NET 3.5. Test Studio has since been upgraded to use .NET 4.0 and requires assembly references using .NET 4.0. I have recompiled that DLL to use .NET 4.0 and attached it to this post.
Regards,Cody
the Telerik team
Test Studio Trainings
I tried using the attached file but unfortunately I wasn't able to add it in the Project References. Please help. Thanks.
Which version of Test Studio do you have installed? Did you try both the TelerikCustomHandlerNET4.zip (which is for .NET 4) and telerikcustomhandler.rar (which is for .NET 3.5)?
Regards,Cody
the Telerik team
Test Studio Trainings
I'm using a Trial Version 2012.1.719.0. And yes i cannot add both the 3.5 and 4.0 versions
With Trial Version 2012.1.719.0 you should be using TelerikCustomHandlerNET4.zip. Could you please share with me what happens when you try? Here's a video showing it working just fine on my machine using the same Telerik build as you. I used Jing to record this video. it's a good free screen recorder.
Greetings,Cody
the Telerik team
Test Studio Trainings
I am sorry I forgot to include the link to my video: http://www.screencast.com/t/dfgcvNReg
Greetings,Cody
the Telerik team
Test Studio Trainings
I suspect I know what the problem is. You may be missing the .NET 4 reference assemblies (see first attached screen shot) that this DLL relies on. To fix this you must download and install the Windows 7 SDK. Note you only need to select the Reference Assemblies as shown in the second attached screen shot.
Please let me know whether or not this solves the problem.
Cody
the Telerik team
Test Studio Trainings