Telerik Forums
Testing Framework Forum
9 answers
321 views
Hi,

I'm having an issue running automated tests driving a silverlight app.  I've gone through all the browser configuration and checked I can run sample tests without an issue, so it's likely to be something wrong in my code.

The Manager settings are initialised as:

 var settings = new Settings
                               {
                                   EnableSilverlight = true,
                                   ExecutionDelay = 50,
                                   EnableUILessRequestViewing = false,
                                   QueryEventLogErrorsOnExit = false,
                                   EnableScriptLogging = false,
                                   AnnotateExecution = true,
                                   AnnotationMode = AnnotationMode.All,
                                   RecycleBrowser = true,
                                   DefaultBrowser = BrowserType.InternetExplorer,
                               };


The browser is connecting via https with navigation and automation on htmlinput elements working OK, but whenever it tries to connect to the silverlight app I get the stack trace below - tested on two seperate machines (one server 2003 x86,  one windows 7 x64):

ArtOfTest.WebAii.Exceptions.ExecuteCommandException : ExecuteCommand failed!

InError set by the client. Client Error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x000003E9): System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.

at System.RuntimeType.get_GenericParameterPosition()

--- End of inner exception stack trace ---

at System.Windows.Browser.ManagedObjectInfo.Invoke(ManagedObject obj, InvokeType invokeType, String memberName, ScriptParam[] args)

at System.Windows.Hosting.ManagedHost.InvokeScriptableMember(IntPtr pHandle, Int32 nMemberID, Int32 nInvokeType, Int32 nArgCount, ScriptParam[] pArgs, ScriptParam& pResult, ExceptionInfo& pExcepInfo)

--- End of inner exception stack trace ---

at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)

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.InternetExplorer.JsObjectWrapper.Call(String methodName, Object[] args)

at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessSilverlightCommand(BrowserCommand request)

at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)

BrowserCommand (Type:'Silverlight',Info:'NotSet',Action:'NotSet',Target:'ElementId (tagName: 'object',occurrenceIndex: '0')',Data:'{"Method":null,"Property":null,"Reference":null,"Reference2":null,"Type":10,"Value":"FrameworkElement;CheckBox;ChildWindow;ComboBox;DataGridCell;DataGridRow;DataGrid;RadioButton;RepeatButton;DataGridCellsPresenter;DataGridColumnHeader;DataGridColumnHeadersPresenter;DataGridDetailsPresenter;DataGridFrozenGrid;DataGridRowHeader;DataGridRowsPresenter;Calendar;CalendarButton;CalendarDayButton;CalendarItem;DatePicker;DatePickerTextBox;GridSplitter;PreviewControl;TabControl;TabItem;TabPanel;Shape;Path;Ellipse;Line;Polygon;Polyline;Rectangle;Glyphs;Panel;Image;Canvas;TextBlock;MediaElement;InkPresenter;MultiScaleImage;StackPanel;Control;TextBox;PasswordBox;Grid;ItemsControl;Border;ContentControl;ContentPresenter;ItemsPresenter;Popup;UserControl;ButtonBase;Button;ToggleButton;Selector;HyperlinkButton;ListBox;RangeBase;ScrollBar;Thumb;ScrollContentPresenter;ScrollViewer;Slider;ToolTip;ProgressBar;ListBoxItem;ComboBoxItem;VirtualizingStackPanel;"}',ClientId:'Client_d284ca17-4bc1-4219-a0e9-56a2af98f06b',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x000003E9): System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.

at System.RuntimeType.get_GenericParameterPosition()

--- End of inner exception stack trace ---

at System.Windows.Browser.ManagedObjectInfo.Invoke(ManagedObject obj, InvokeType invokeType, String memberName, ScriptParam[] args)

at System.Windows.Hosting.ManagedHost.InvokeScriptableMember(IntPtr pHandle, Int32 nMemberID, Int32 nInvokeType, Int32 nArgCount, ScriptParam[] pArgs, ScriptParam& pResult, ExceptionInfo& pExcepInfo)

--- End of inner exception stack trace ---

at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)

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.InternetExplorer.JsObjectWrapper.Call(String methodName, Object[] args)

at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessSilverlightCommand(BrowserCommand request)

at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')

InnerException: none.

at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)

at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)

at ArtOfTest.WebAii.Silverlight.SilverlightProxy.ExecuteSLCommand(SilverlightCommand cmd)

at ArtOfTest.WebAii.Silverlight.SilverlightProxy.PublishKnownControlTypes(List`1 knownTypes)

at ArtOfTest.WebAii.Silverlight.SilverlightApp.Connect(Int32 timeout)

at ArtOfTest.WebAii.Silverlight.SilverlightApp.Connect()

at ArtOfTest.WebAii.Silverlight.SilverlightAppsList.get_Item(Int32 index)

Helpers\TestHelper.cs(15,0): at Insurer.Analytics.Acceptance.Test.Helpers.TestHelper.get_SilverlightApp()

Cody
Telerik team
 answered on 10 Mar 2011
1 answer
199 views
I'm trying to press Shift+Home on my control, I've tried a few things, but the control always interprets the key presses as if the shift key wasn't pushed (i.e. it still acts on the Home key, but not as if shift was pushed). The control works fine in manual testing.

The weird thing is, if at any point I stop the code between the shift key down and the shift key up, then the shift key is definitely pushed as every program in Windows acts like it is, even the program I'm trying to test.
Here's what I've tried:
1)*
myFrameworkElement.User.KeyDown(Keys.ShiftKey);
myFrameworkElement.User.KeyPress(Keys.Home);
myFrameworkElement.User.KeyUp(Keys.ShiftKey);
2)
myFrameworkElement.User.KeyPress(Keys.ShiftKey | Keys.Home);
3)**
silverlightApp.Desktop.KeyBoard.KeyDown(Keys.ShiftKey);
silverlightApp.Desktop.KeyBoard.KeyPress(Keys.Home);
silverlightApp.Desktop.KeyBoard.KeyUp(Keys.ShiftKey);
4)
silverlightApp.Desktop.KeyBoard.KeyPress(Keys.ShiftKey | Keys.Home);
5)
var keys = Keyboard.KeysFromString("Shift+Home");
silverlightApp.Desktop.KeyBoard.KeyPress(keys);

Any help on how to accomplish this would be great.

* myFrameworkElement is ArtOfTest.WebAii.Silervlight.FrameworkElement
**silverlightApp is ArtOfTest.WebAii.Silervlight.SilverlightApp
Ray
Top achievements
Rank 1
 answered on 08 Mar 2011
1 answer
132 views
Hi,

I'm using WebAii to write automated tests for a Silverlight application.  Recently, some the RadComboBoxes in the app have been changed to use the VirtualizingStackPanel.  The following test code now fails with the following error:  

  • Code Sample - int saveCount = radComboBox.Items.Count;
  • Error Generated - System.TimeoutException:  Wait for condition has timed out.

This will happen on any statement that attempts to reference the Telerik.WebAii.Controls.Xaml.RadComboBox Items property,

How do I get this to work (or what's the work around) when the VirtualizingStackPanel is used with the RadComboBox control?

Thanks.

Joel
Boyan
Telerik team
 answered on 07 Mar 2011
3 answers
159 views
Hi Guys,

I am currently running IE6, with the latest WebAii, and when I set the browser to InternetExplorer I get the following:
SetUp : System.ApplicationException : Exception thrown attempting to launch Internet Explorer. Please make sure Internet Explorer is properly installed and you are able to launch it.
  ----> System.TimeoutException : Wait for condition has timed out
at ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions.LaunchNewBrowserInstance(Int32 timeout, ProcessWindowStyle windowStyle, String pipename)
at ArtOfTest.WebAii.Core.Manager.LaunchNewBrowser(BrowserType browserToLaunch, Boolean waitForBrowserToConnect, ProcessWindowStyle windowStyle, String arguments)
at ArtOfTest.WebAii.Core.Manager.LaunchNewBrowser(BrowserType browserToLaunch)
at WebAiiTestClass.TestBase.TestBaseSetUp() in TestBase.cs: line 21
--TimeoutException
at ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo)
at ArtOfTest.Common.WaitSync.For(Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout)
at ArtOfTest.Common.WaitSync.For(Predicate`1 predicate, T target, Int32 timeout)
at ArtOfTest.Common.Win32.WindowManager.Attach(ref IntPtr handle, Boolean findTabWindow, Boolean loadClr, ref IntPtr hookId)
at ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions.LaunchNewBrowserInstance(Int32 timeout, ProcessWindowStyle windowStyle, String pipename)

The browswer opens but sits on about:blank.

Note that I am only using the WebAii, and not the testing suite.

The same test works fine in Firefox, and I do not have access to chrome to test it.

I have all the settings set according to:

http://www.artoftest.com/support/webaii/topicsindex.aspx?topic=configureie6

But still no help.

Unfortunately upgrading to IE7+ is not an option. Please any help would be greatly appreciated.

Also just incase it helps:

namespace WebAiiTestClass
{
    [TestFixture]
    public abstract class TestBase : BaseTest
    {
        protected internal SilverlightApp App { get; private set; }
 
        [SetUp]
        public void TestBaseSetUp()
        {
            var settings = GetSettings();
            settings.EnableSilverlight = true;
            settings.LogLocation = @"C:\Documents and Settings\alicross\My Documents\Dev\UI\Testing\WebAiiTestClass";
 
            Initialize(settings, NUnit.Core.TestContext.Out.WriteLine);
            Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
            ActiveBrowser.NavigateTo("http://localhost:4882/TestPage.aspx");
            App = ActiveBrowser.SilverlightApps()[0];
        }
 
        [TearDown]
        public void TestBaseTearDown()
        {
            CleanUp();
        }
 
        [TestFixtureTearDown]
        public void TestBaseFixtureTearDown()
        {
            ShutDown();
        }
    }
}

Thanks for your help guys

Daniel Djambov
Telerik team
 answered on 07 Mar 2011
1 answer
110 views

How can I use a variable in the code "searchLnk = ActiveBrowser.Find.ByContent(contentvalue);" 

Where conentvalue was previously defined by contentvalue = “btnG”;

Rather than searchLnk = ActiveBrowser.Find.ByContent(”btnG”);


is there a way NOT to have to use a LITERAL value?

thanks joe

Cody
Telerik team
 answered on 05 Mar 2011
5 answers
193 views
Hi all.

As we have to support multi-browser automated tests, the tests must run in both IE and Firefox.
After installing the latest build of WebAii we finally can work fine with both of them.
Still I suspect a funny problem with these browsers because they render non-breakable space ( ) in different manner.
Just have a look at this piece of HTML code:

<a href="http://google.com">mega&nbsp;link</a>

Looks usual.

But now, if I want to find this link by the text it contains, troubles appear.

Settings settings = new Settings(BrowserType.InternetExplorer, "d:\\log\\");
Manager manager = new Manager(settings);
 
manager.Start();
 
manager.LaunchNewBrowser();
manager.ActiveBrowser.NavigateTo("http://aspspider.ws/kovyar/find_bycontent_test.htm");
manager.ActiveBrowser.WaitUntilReady();
 
Element element = manager.ActiveBrowser.Find.ByContent("mega link"); //null in both browsers, the desired way to find the element
 
Element element1 = manager.ActiveBrowser.Find.ByContent("mega link".Replace(' ', (char)160)); //null in IE
Element element2 = manager.ActiveBrowser.Find.ByContent("mega link".Replace(" ", "&nbsp;"));  //null in FF
 
Assert.IsNotNull(element1); //here fails IE
Assert.IsNotNull(element2); //here fails FF
 
manager.Dispose();

You can switch the browser type right in the first line of the code.
The general trouble is that I cannot process this link in the same way in FF and IE.
The second problem is that the types of spaces in the text can change (so the appearance of the text would be the same, but spaces would be different).

So we need a way of finding elements on the page which will not depend on:
1) browser type
2) type of spaces used by developers.

It would be really good if there is such a way, because our tests use Find.ByContent very often.

Thanks,
Yaroslav

Konstantin Petkov
Telerik team
 answered on 03 Mar 2011
6 answers
89 views
Hi, I downloaded Web UI Test Studio Developer version to automate Silverlight Application. I can't automate it because Web UI test Studio doesn't record anything. Finally I find our developer uses frameset .

When I automate the same Silverlight Application without frameset , I can automate it.

Does it support frameset ? Do you have any way to automate the Silverlight application with Frameset?

Thanks,

Amy
Daniel Djambov
Telerik team
 answered on 03 Mar 2011
3 answers
144 views
We stored values in our session in our site.

I see we can access cookies, but how can I verify session values?
Cody
Telerik team
 answered on 02 Mar 2011
9 answers
405 views
I have a website with several frame in an frameset:

...
<frameset rows="100%,0,0,0" onload="gotoUrl('/here_is_the_url',null)">
    <frame frameborder="0" name="frame1" src="about:blank">
       <html>
           <head>...</head>
           <body>
              <div id="divID">...</div>
           </body>
        </html>
    </frame>
    <frame scrolling="no" noresize="" frameborder="0" name="frame2" src="about:blank">...</frame>
    <frame scrolling="no" noresize="" frameborder="0" name="frame3" src="about:blank">...</frame>
    <frame scrolling="no" noresize="" frameborder="0" name="frame4" src="about:blank">...</frame>
    <noframes>
        <body bgcolor="#FFFFFF">
            <p>your browser does not handle frames</p>
        </body>
    </noframes>
</frameset>
...

In my case, I want to find the div element byID. I tried:
Browser frame = Manager.ActiveBrowser.Frames["frame1"];
Element divEle = frame.Find.byId("divID");

but I get a FindException. I debugged and I noticed that the DOM root element of the frame1 is null. Any DOM refresh had no effect. I tried to refresh root browser an all frames containing.

I used Firefox 3.5.16 and WebAii 2010.3.1213.0

How can I get the div element?
Cody
Telerik team
 answered on 01 Mar 2011
8 answers
141 views
I tried using HTMLInputText.IsActiveElement but it doesn't seem to work properly.
When running my test:
[Test]
public void GoogleTest()
{
    Manager.LaunchNewBrowser();
    ActiveBrowser.NavigateTo("http://www.google.com");
 
     
    HtmlInputText queryBox = Find.ByName<HtmlInputText>("q");
    Log.WriteLine(queryBox.IsActiveElement.ToString());
    Desktop.Mouse.Click(MouseClickType.LeftClick, queryBox.GetRectangle());
    Desktop.KeyBoard.TypeText("sample", 1000);
     
    Actions.Click(Find.ById("btnG"));
}

I can see that focus is in the url address box and not the search input box. queryBox.IsActiveElement is true so it's incorrect.
I also noticed that ActiveBrowser.NavigateTo works differently than launching the page manually.
In the first case focus is in the url address box in the latter its in search box.

1. Why IsActiveElement wrong?
2. Why NavigatTo works differently than manually?
Cody
Telerik team
 answered on 24 Feb 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?