WebAii outside Testing Framework

10 posts, 0 answers
  1. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 12 Dec 2012 Link to this post


    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
  2. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 14 Dec 2012 Link to this post


    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
  3. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 14 Dec 2012 Link to this post

    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
  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 17 Dec 2012 Link to this post

    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
  5. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 17 Dec 2012 Link to this post

    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
  6. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 17 Dec 2012 Link to this post

    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

  7. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 19 Dec 2012 Link to this post

    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
  8. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 26 Dec 2012 Link to this post

    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
  9. Jose
    Jose avatar
    7 posts
    Member since:
    Dec 2012

    Posted 26 Dec 2012 Link to this post

    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
  10. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 31 Dec 2012 Link to this post

    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
Back to Top