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

how to get and verify the message show in the msgbox.

1 Answer 80 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 21 Jul 2010, 06:38 AM
Is there any API we can use to get the  message display on the messagebox.eg:when user log in to the system the usernam is null,click the log in button ,the warnning message like "please input username".

1 Answer, 1 is accepted

Sort by
0
Kiran
Top achievements
Rank 2
answered on 21 Jul 2010, 07:16 PM

Hi Jack,

Try the below code and let me know if it is working.

I am having a silverlight application. When i click a button it will dispaly a message box with caption "My Message" and text

"Hello World!!!!!!".
Please make sure to give Thread.Sleep() after the button click.

[TestMethod]
        public void MessageBoxTest()
        {
  
            Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
            ActiveBrowser.NavigateTo("http://localhost:2463/SampleApplicationTestPage.aspx");
  
              
            // Get an instance of the running Silverlight Application.
            SilverlightApp  CurrentApplication = ActiveBrowser.SilverlightApps()[0];
            //To activate the silverlight control
            CurrentApplication.Desktop.Mouse.Click(MouseClickType.LeftClick, CurrentApplication.Bounds);
  
            Button btnShowMessageBox = CurrentApplication.Find.ByName<Button>("btnShowMessageBox");
            btnShowMessageBox.User.Click();
  
            Thread.Sleep(2000);
            Window msgBox = null;            
  
            WindowManager winManager = new WindowManager();
            winManager.GetWindows();
            foreach (Window win in winManager.Items)
            {               
                if (win.Caption.Contains("My Message"))
                    msgBox = win; 
            }
  
  
            if (msgBox != null)
            {
               var label= msgBox.AllChildren.OfType<Window>().Where(w => w.ClassName == "Static");
               if (label.FirstOrDefault().Caption == "Hello World!!!!!!!!")
               {
                   msgBox.Close();
               }
            }
             
            Thread.Sleep(4000);
  
            
             
        }

Thanks
Kiran
Tags
General Discussions
Asked by
Jack
Top achievements
Rank 1
Answers by
Kiran
Top achievements
Rank 2
Share this question
or