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

WebAii outside Testing Framework

9 Answers 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jose
Top achievements
Rank 1
Jose asked on 12 Dec 2012, 04:52 PM

Hello,

I am trying to use WebAii to control a WebApplication outside the context of the Testing Framework,
i.e., I am building a standalone application which uses WebAii, to control another application.
The problem is that I can't seem to control Silverlight controls from this standalone application.
When I run the same code within a TestMethod everything work.
Can you help me with this?

Many thanks in advance.

Jose Pacheco

9 Answers, 1 is accepted

Sort by
0
Jose
Top achievements
Rank 1
answered on 14 Dec 2012, 03:07 PM

Hello again,

I am trying to isolate the problem, and so far this is the scenario.
I have a TabControl, I click on the right TabItem (I've verified this with AnnotateExecution = true) but the tab is not selected.
When I click on it myself everything works well, when WebAii clicks, nothing happens.
Any suggestions?

Many thanks in advance.

Jose Pacheco
0
Jose
Top achievements
Rank 1
answered on 14 Dec 2012, 04:49 PM
Settings mySettings = new Settings();
mySettings.Web.DefaultBrowser = BrowserType.InternetExplorer;
mySettings.Web.EnableSilverlight = true;
mySettings.AnnotateExecution = true;
Manager myManager = new Manager(mySettings);
myManager.Start();
myManager.LaunchNewBrowser();
myManager.ActiveBrowser.NavigateTo("http://localhost/", false);
 
myManager.ActiveBrowser.Find.ByExpression<HtmlInputText>("id=txtUserName").Text = "name";
myManager.ActiveBrowser.Find.ByExpression<HtmlInputSubmit>("id=btnLogin").Click(true);
 
SilverlightApp app = null;
do
{
    try
    {
        myManager.ActiveBrowser.ContentWindow.SetFocus();
        myManager.ActiveBrowser.RefreshDomTree();
        app = myManager.ActiveBrowser.Frames.ById("TargetFrame").SilverlightApps()[0];
    }
    catch { System.Threading.Thread.Sleep(100); }
} while (app == null);
 
TabControl tabControl = app.Find.ByName<TabControl>("TabControl1");
tabControl.Wait.ForExists(30000);
app.OwnerBrowser.WaitUntilReady();
 
tabControl.TabItems[0].User.Click();
app.OwnerBrowser.WaitUntilReady();
tabControl.Refresh();

Here is the code I am using, and I am attaching an image of the result (tab clicked but not selected).

Any suggestions will be GREATLY appreciated.

Jose Pacheco
0
Plamen
Telerik team
answered on 17 Dec 2012, 11:31 AM
Hello Jose,

One thing you can try is to use the "EnsureClickable" method right before the Click step.
tabControl.TabItems[0].EnsureClickable();

This will ensure that the tab item element is visible and available for simulated user actions. 

If this doesn't work, please provide the means to reproduce the issue locally(either in your app or on a public site). Alternatively, you can capture a Fiddler trace using FiddlerCap and send it to us in a zip file. If you deem that information too sensitive for this forum, you can create a support ticket and attach it there. Thanks for providing the information we need to best assist you.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Jose
Top achievements
Rank 1
answered on 17 Dec 2012, 02:46 PM
Hello,

Many thanks for the suggestion, but sadly it does not work.
I've stripped down my project in two different ways, one a console application with roughly the code above,
another with a test project with just one test, with the same code.
Fact is that the console application doesn't work, and the test project works.
Is anyhow the Silverlight control related to be within a test project?
How do I turn this around?

Many thanks in advance.

Jose Pacheco
0
Jose
Top achievements
Rank 1
answered on 17 Dec 2012, 03:27 PM
Hello again,

I've done some further tests.
I've created a fresh test project and from visual studio everything works.
I've changed the project's output type to console application, ran it from a console and it didn't work.
I've reverted the project's output type back to class library and run it from a console using mstest.exe and it worked again.

It seems that somehow the behavior of WebAii Silverlight control is tight to some kind of initialization done
by the mstest platform. Is that so? How do I turn it around?

Thanks again for your help.

Jose Pacheco

0
Plamen
Telerik team
answered on 19 Dec 2012, 03:53 PM
Hello Jose,

I have tried to reproduce the problem you are experiencing executing different mouse actions against different Silverlight applications, but I wasn't able to replicate any issues when executing via Console Application. Unfortunately issues like this are extremely difficult to troubleshoot without a local reproduction. Is there any chance we can get direct access to your application for a local repro? It not, please ask your developers to put together a small sample app that demonstrates the issue and provide access to that.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Jose
Top achievements
Rank 1
answered on 26 Dec 2012, 04:48 PM
Hello again,

I am still having the same problem.
I wonder if you could show me an example of a Console Application controlling a Silverlight Application and clicking on a TabItem.
Many thanks in advance.

Jose Pacheco
0
Jose
Top achievements
Rank 1
answered on 26 Dec 2012, 05:52 PM
Hello again,

Strange enough if I select a tab by setting the IsSelected property it works.

tabControl.TabItems[0].IsSelected = true;    // works
tabControl.TabItems[0].User.Click();         // doesn't work

Any suggestion?

Jose Pacheco
0
Cody
Telerik team
answered on 31 Dec 2012, 05:49 PM
Hi Jose,

The property TabItems has been deprecated. You should be using TabItemElements instead. Also TabItemElements has a .Click method. Please try:

tabControl.TabItemElements[0].Click();

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
Jose
Top achievements
Rank 1
Answers by
Jose
Top achievements
Rank 1
Plamen
Telerik team
Cody
Telerik team
Share this question
or