This is a migrated thread and some comments may be shown as answers.
Can not assert the right number of elements in a ListBox populated dynamically in a window
11 Answers 51 Views
This is a migrated thread and some comments may be shown as answers.
Mathieu Estratat
Top achievements
Rank 1
Mathieu Estratat asked on 24 Aug 2011, 09:23 AM
Hi,
I am facing a problem accessing the number of elements in a ListBox populated dynamically in a window:
- If I search the window before populating the datamodel of the list box, I can not retreive the good number of items.
- If I search the window after the populate action, I have the right number of items

I join 2 zip, the first (SilverlightApplication27.zip) contains a solution launching the application (a mainwindown with 2 buttons, one opening a window, the other populating a data model observed by the ListBox in the opened window), the second (TestSolution.zip) contains a solution providing Nunit tests (one working the other not working).

How can I do to make the failing test pass ? 

Behind this simple use case is our real application where we need to add the items in the list box from the window itself (button AddElement) and remove line from the DeleteElementButton in each item of the listbox. 

Thanks,

Kind regards,

Mathieu

11 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 26 Aug 2011, 07:51 AM
Hello Mathieu Estratat,

I'm sorry for the late response. I was able to find what caused the error when retrieving the ListBox items. 
Here is your sample with just a slight modification to your code:
public void ListBoxInWindowFailingTest()
        {
            Manager.Settings.EnableSilverlight = true;
  
            // Launch a browser instance
            Manager.LaunchNewBrowser();
  
            // The active browser
            ActiveBrowser.NavigateTo("http://localhost:62922/index.html");
              
            this.ActiveBrowser.WaitUntilReady();
            this.ActiveBrowser.RefreshDomTree();
  
            SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
  
            Button show = app.Find.ByName<Button>("showButton");
            show.User.Click();
  
            RadWindow window = app.Find.ByName<RadWindow>("AWindow");
            Button newcf = app.Find.ByName<Button>("populateButton");
            newcf.User.Click();
            try
            {
                ListBox lb = window.Find.ByName<ListBox>("Elements");
                Assert.AreEqual(3, lb.Items.Count);
                lb.Refresh();
                IList<RadButton> deleteButtons = lb.Find.AllByName<RadButton>("DeleteElementButton");                    
                Assert.AreEqual(3, deleteButtons.Count);
            }
            catch (TimeoutException e)
            {
                Log.WriteLine("Listbox : " + e);
            }
        }
The reason for the wrong count of the items was that the list box was not refreshed yet. So adding this line "lb.Refresh();" should solve the problem.

Please try it, and let me know if it works!

Greetings,
Plamen
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
Mathieu Estratat
Top achievements
Rank 1
answered on 12 Sep 2011, 11:44 AM
Hi Plamen,
Thanks for your help and please apologize for the late answer.
I tried your code without any success ... The number of "DeleteElementButton" is still 0, while 3 is expected.
The only difference between the two tests is the date at which the window is searched and even with a refresh on the window itself, there is no "DeleteELementButton" retreived ....

Does this test not fail on your box  ? (with your updates) 

Kind Regards

Mathieu




0
Plamen
Telerik team
answered on 13 Sep 2011, 11:45 AM
Hi Mathieu Estratat,

I've checked the code again and it works as expected. Here is a video demonstrating how it works http://screencast.com/t/Wbc14Ydq. Find the attached sample from the video.

Please try it and let me know if it works!

Kind regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mathieu Estratat
Top achievements
Rank 1
answered on 14 Sep 2011, 09:57 AM
Hi Plamen,

thanks for your answer and the video, nevertheless, I am sorry to have to tell to you that this code is still not working on my box, the number of deleteButton is still 0 ... I have also tried with the latest internal build (2011.1.829) without anymore success.
I am launching the application to be tested (SilverlightApplication27) from VisualStudio (I have tried with and without debugging).
Do you have an idea of what could be wrong on my box ?

Kind regards,
Mathieu

0
Plamen
Telerik team
answered on 16 Sep 2011, 01:59 PM
Hello Mathieu Estratat,

Sorry for the late response, I have tried to reproduce your issue on a different environments but everything works fine. Which version of Silverlight are you using? Which version of Internet Explorer and NUnit?

To eliminate the version of NUnit, as possibility I've created the same test using the VsUnit template. Please run it from Visual Studio as shown on this video http://screencast.com/t/iM1B8k7jC2t  and let me know of the results!  

Regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Plamen
Telerik team
answered on 16 Sep 2011, 02:07 PM
Hello Mathieu Estratat,

Find the attached project!

Greetings,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mathieu Estratat
Top achievements
Rank 1
answered on 17 Sep 2011, 08:52 AM
Hi Plamen,

Thanks for your answer and the sample. 
I have launched the test on VSUnit without anymore success.... 
I have tried both with ie 8 and ie 9.
For Nunit (for previous runs) the version was 2.5.10.
Next step, on monday, will be to launch the test on another box ...
Thanks you very much for your help.
I will come back to you on monday after the test.

Greetings,
Mathieu
0
Plamen
Telerik team
answered on 17 Sep 2011, 04:36 PM
Hi Mathieu Estratat,

It's really a strange issue, I'll be waiting for your response on this. Meanwhile we'll continue in our attempts to reproduce the issue on different environments.  

Kind regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mathieu Estratat
Top achievements
Rank 1
answered on 19 Sep 2011, 08:51 AM
Hi Plamen,
we have tested on another box and the problem is still the same.... 
What is your environment of test please ? 
Kind regards,
Mathieu

0
Plamen
Telerik team
answered on 20 Sep 2011, 01:58 PM
Hello Mathieu Estratat,

After many attempts, finally we were able to replicate your problem on a virtual machine. Unfortunately we are still trying to find what caused the problem in order to fix it. It's really strange, because there is no difference between the configuration of the VM that is failing and the others on which the same test passes. We'll continue working on this issue and we'll let you know when we have a solution.

I'm sorry for the inconvenience caused!     

Greetings,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mathieu Estratat
Top achievements
Rank 1
answered on 20 Sep 2011, 05:18 PM
Hi Plamen,
good to read that. Let me know when you find the problem please. 
Thanks for the update, 
Greetings,
Mathieu
Asked by
Mathieu Estratat
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Mathieu Estratat
Top achievements
Rank 1
Share this question
or