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

Silverlight testing with multiple browsers

9 Answers 94 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John Swartzentruber
Top achievements
Rank 1
John Swartzentruber asked on 30 Sep 2010, 02:58 PM
I need to write a test where I have two browsers open at the same time. In really simplified terms, this is what I need to do:

1. Open one browser and create and save a data file (involves drag and drop)
2. Open another browser and open the data from step #1
3. Activate and focus the first browser window
4. Modify the data in the first browser (involves drag and drop)
5. Refresh the second browser and verify that it has the data from step #3.

The first three steps are working fine. The problem is with step #4. It appears that I cannot click or drag an element in the first browser window. When I call "elem.User.Click()" on a FrameworkElement in the first window, it flashes the second browser window, but does nothing on the first browser window, which contains the FrameworkElement.

I understand that the ActiveBrowser property cannot be changed, so the ActiveBrowser is still the second browser instance, but in this case, I am calling the Click() directly on the element in the first browser window.

In my tests, I've verified that if I close the second browser window, step #4 works correctly, but it's hard to run step #5 if the browser is already closed.

Is there any way for me to get this to work? Any chance better multiple browser support is coming? I think I am running the latest version of WebAii (it looks like 2010.2.830.0 in the GAC).

Thanks for your help.

9 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 30 Sep 2010, 11:29 PM
Hi John Swartzentruber,

Instead of using ActiveBrowser try referencing the browser window you want to interact with via the Browser collection:

Manager.Browsers[0] or Manager.Browsers[1]. 

The Browsers collection contains a list of all open browser windows that WebAii is currently connected to.

Kind regards,
Cody
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
0
John Swartzentruber
Top achievements
Rank 1
answered on 01 Oct 2010, 07:55 PM
I think you misunderstood or missed parts of my original message. I already have separate references to my two browser instances. The problem is that I can't click on an element (in this case a listbox item) in the first browser. I am not using the ActiveBrowser property in my code. This is how it appears to me:

1. Open first browser and initialize listbox
2. Clicking on a listbox item selects it
3. Open second browser
4. Call SetFocus and SetActive on first browser's window
5. Attempt to click on a listbox item

At this point, the second browser window flashes as if I were trying to do something in it when it was not focused. The listbox item I am trying to click on (in WebAii) is not selected.

If I close the second browser (i.e, add a step 3b), then the click works correctly.

I am not using the ActiveBrowser property in any of this, but I wonder if there might be some internal code in WebAii that is using it.
0
Cody
Telerik team
answered on 01 Oct 2010, 10:06 PM
Hi John Swartzentruber,

Can you show me a code snippet for steps 4 & 5? I find just calling SetFocus is enough to overcome the problem you describe like this:

// Scroll to get fresh data
ActiveBrowser.Window.SetFocus();
// Each TurnMouseWheel call scrolls 3 lines on my machine
Pages.Silverlight4Controls1.SilverlightApp.RadGridView1Radgridview0.User.TurnMouseWheel(500, MouseWheelTurnDirection.Backward, false);
Pages.Silverlight4Controls1.SilverlightApp.RadGridView1Radgridview0.User.TurnMouseWheel(500, MouseWheelTurnDirection.Backward, false);
Pages.Silverlight4Controls1.SilverlightApp.RadGridView1Radgridview0.User.TurnMouseWheel(500, MouseWheelTurnDirection.Backward, false);
Pages.Silverlight4Controls1.SilverlightApp.RadGridView1Radgridview0.User.TurnMouseWheel(500, MouseWheelTurnDirection.Backward, false);
Pages.Silverlight4Controls1.SilverlightApp.RadGridView1Radgridview0.User.TurnMouseWheel(500, MouseWheelTurnDirection.Backward, false);
Pages.Silverlight4Controls1.SilverlightApp.RadGridView1Radgridview0.User.TurnMouseWheel(500, MouseWheelTurnDirection.Backward, false);

Regards,
Cody
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
0
John Swartzentruber
Top achievements
Rank 1
answered on 04 Oct 2010, 04:12 PM
Our code is based on various baseclass functions and helpers specific to our program. I'm not sure I can strip it down enough to demonstrate. If I finish my other sprint items in time, I'll attempt to create a simple demonstration program. In the mean time, here is some lightly edited WebAii code. The final Click() call is where I see the problem. The line that is commented out with ?? shows the Close() call that makes things work (but causes later inconveniences).

**

            TestContext.WriteLine("*** Document locking test ***" + System.Environment.NewLine);

            SilverlightApp app1 = this.App;

            Browser firstBrowser = ActiveBrowser;

            TestContext.WriteLine("Create a new document with one gSym. Name it DocumentLockingTest");

            // Drag to an empty area
            var documentView1 = App.Find.ByType("DocumentView");
            List<FrameworkElement> list = new List<FrameworkElement>();

            // Start a search
            List<string> things = new List<string>();
            things.Add("cdt");

            ListBox resultsListbox = SearchFor(things[0], true);
            IList<ListBoxItem> resultItems = resultsListbox.Find.AllByType<ListBoxItem>();
            TestUtility.IsTrue(resultItems.Count > 1, TestContext, "Verify at least two search results are returned");

            list.Add(resultItems[0]);
            FrameworkElement gSym = this.CreateElementBasedOn(list, documentView1, TypeGSym, 1);

            TestContext.WriteLine("2. Open a new browser and open this document again. Verify that ");

            // Open browser
            TestContext.WriteLine("Open second instance of OurProgram");
            this.StartOurProgram(false);

            Browser secondBrowser = ActiveBrowser;
            var app2 = ActiveBrowser.SilverlightApps()[0];

            TestContext.WriteLine("3. Modify the original document by adding a new symbol");
            // ?? WORKS IF I CLOSE, DOES NOT WORK IF I DO NOT CLOSE -- secondBrowser.Close();  // WebAii won't let us work in first window while second one is still open
            firstBrowser.Window.SetActive();
            firstBrowser.Window.SetFocus();
            list.Clear();
            list.Add(resultItems[1]);
            list[0].ScrollToVisible();
            list[0].Wait.ForVisible();
            list[0].User.Click();
0
David
Top achievements
Rank 1
answered on 08 Oct 2010, 04:43 PM
Any resolution to this issue?  I am having the exact same problem, the browsers are not able to activate themselves once in the background.  They just blink in the taskbar, but the click events do not actually take place.

Thanks!
0
Cody
Telerik team
answered on 08 Oct 2010, 05:49 PM
Hello David,

Are you running Window 7? We recently discovered a problem with our SetFocus call on that specific OS. We do not have a fix for that OS yet.

Best wishes,
Cody
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
0
John Swartzentruber
Top achievements
Rank 1
answered on 08 Oct 2010, 05:51 PM
I'm not David, but I started this thread. I'm running Windows Server 2008 R2 with all of the Windows 7 user experience stuff turned on. I assume that is equivalent to Windows 7 from your perspective.
0
David
Top achievements
Rank 1
answered on 08 Oct 2010, 05:55 PM
I am Running Windows XP
0
Cody
Telerik team
answered on 29 Oct 2010, 08:18 PM
Hi David & John,

I have confirmed we have a bug here. I have filed bug 77327 to address it. We should be able to have it fixed in our upcoming Q3 release, due out within two weeks.

Best wishes,
Cody
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
Tags
General Discussions
Asked by
John Swartzentruber
Top achievements
Rank 1
Answers by
Cody
Telerik team
John Swartzentruber
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or