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

[Solved] Getting the elements in Silverlight Control to Active Screen/Browser.

3 Answers 62 Views
Silverlight WebAii RadControls
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mithul Shah
Top achievements
Rank 1
Mithul Shah asked on 09 Feb 2010, 07:10 AM

Hi,

 

I am using WebAii Automation Framework (2.0.7.0) to automate a web application which has Silverlight controls in it. I am caught up with a issue and hence need your help in resolving it.

 

I have a web page which has Telerik RadPanel in it. This is an expandable RadPanel. When I click on the RadPanel it expands and a Silverlight control is being loaded in this RadPanel. There is a hyperlink button which is loaded with this Silverlight control.

 

My use case is, I need to click on the hyperlink button.

[BLOCK 1] Here is the code that I have to expand the RadPanel.

 

            MilestoneControl = Find.ById("panelBarMilestonesItem");

            ITargetElement[] GetMilestoneTabs = MilestoneControl.GetChildren();

            Element MilestoneTab = (Element)GetMilestoneTabs[0];           

            Actions.ScrollToVisible(MilestoneTab);

            Manager.Settings.ExecutionDelay = 1000;

            Actions.ScrollToVisible(MilestoneTab);

            Actions.Click(MilestoneTab);

            ActiveBrowser.WaitUntilReady();

            Manager.Settings.ExecutionDelay = 1000;

            Thread.Sleep(2000);

The above code gets the RadPanel to active screen/browser (visible to user) and expands the panel so that the Silverlight control is loaded.

 

[BLOCK 2] Here is the code through which I am trying to find the hyperlink button in the Silverlight control and click it.

            try

            {

                app = ActiveBrowser.SilverlightApps()[1];

                //string s = app.VisualTree.Root.ToXml();

                app.FindName<HyperlinkButton>("hyperlinkAddMilestone").ScrollToVisible();

                Manager.Settings.ExecutionDelay = 1000;

                app.FindName<HyperlinkButton>("hyperlinkAddMilestone").EnsureClickable();

                Manager.Settings.ExecutionDelay = 1000;

                app.FindName<HyperlinkButton>("hyperlinkAddMilestone").User.Click();

                Manager.Settings.ExecutionDelay = 1000;

}

The above code is followed by BLOCK 1 code. I have used both the methods ScrollToVisible() and EnsureClickable() to make sure that the element is visible or is available in the active screen to perform a user action. However these methods doesn’t bring the element to active screen and when Click() method is called there is an exception that raised. Here is the exception:

 

Exception:

Test method BgRoadmap.AddProductScript1.AddProduct threw exception:  ArtOfTest.WebAii.Exceptions.LogErrorException: An error log has been detected. Error 'Could not load the Milestone ControlPoint (140, 1217) outside bounds of browser window: (0, 133, 1280, 843)'.

 

Can you please help me in resolving this issue. Thanks,

 

Regards,

Mithul.

3 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 09 Feb 2010, 08:17 AM
Hi Mithul Shah,

Thank you for contacting us.

To help handling such scenarios in Silverlight the framework provides a helpful API. You can try with element.Wait.ForNoMotion() that internally validates the element animation is completed. You can read more on that on this blog post (scroll to the task #6 at the bottom).

Looking at your code, I suggest you review this help article describing the Settings class. Please make sure you initialize the settings in the TestInitialize section in VS (or Setup section in NUnit) only. Any other updates of the settings will not take effect.

Best wishes,
Konstantin Petkov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Mithul Shah
Top achievements
Rank 1
answered on 09 Feb 2010, 02:40 PM

Hi Petkov,

 

Thanks for the response. The method that you have suggested did not work out for me. The element is successfully loaded and there is nothing like we need to wait for more time for the event to load.

 

The issue is that an exception is raised when I call the Click method on the hyperlink button and it is because this element is not visible to screen.

 

Incase while the script is running if I put a break point at Click() and if I manually scroll down the web page and then execute the script then there is no exception that’s raised. So by this we can say that the element is successfully loaded but EnsureClickable() and ScrollToVisible() methods are not making the element visible.

 

Is this because the RadPanel was collapsed when I started the script earlier and now it’s in expanded state.

 

Please let me know if case if I am not clear in explaining you the issue. If required I can capture the video of my application and can send it to you to make you understand it more clearly.

 

Thanks,

Mithul.

0
Missing User
answered on 09 Feb 2010, 07:44 PM
Hello Mithul,

Please try adding an:

if (!ActiveBrowser.Window.IsMaximized)
ActiveBrowser.Window.Maximize();

to the beginning of Block 2 and switching the Manager.Settings.ExecutionDelay lines to Thread.Sleep(1000); instead.

Greetings,
Nelson SIn
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Silverlight WebAii RadControls
Asked by
Mithul Shah
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Mithul Shah
Top achievements
Rank 1
Missing User
Share this question
or