How to access alert pop-up buttons?

Apr 28, 2012 at 1:26 AM

Hi automation folks,

I am new to CUITe and having a hard time trying to get the OK button to click in an alert pop-up. I've been able to get the innertext for the div but am lost from there on.

Would anybody like to give some info on how to do this or atleast where point me to where I find info. on how to figure this out?

 

Thanks in advance.

Coordinator
Apr 28, 2012 at 2:03 AM

Hi a_m_e,

I've just checked in some sample code to demonstrate this.

Changeset #16181

Sample_CUITeTestProject\Tests_for_HtmlControls.cs

        [TestMethod]
        public void Test_Value_As_SearchParameterKey()
        {
            string baseDir = Path.GetDirectoryName(Assembly.GetAssembly(this.GetType()).CodeBase);
            CUITe_BrowserWindow bWin = CUITe_BrowserWindow.Launch(baseDir + "/TestHtmlPage.html", "A Test");
            bWin.Get<CUITe_HtmlInputButton>("Value=Log In").Click();

            UITestControl popup = new UITestControl(bWin);
            popup.TechnologyName = "MSAA";
            popup.SearchProperties.Add("ClassName", "#32770", "Name", "Message from webpage");
           
            UITestControl btnOK = new UITestControl(popup);
            btnOK.TechnologyName = "MSAA";
            btnOK.SearchProperties.Add("ControlType", "Button", "Name", "OK");
            Mouse.Click(btnOK);

            bWin.Close();
        }

Coordinator
Sep 6, 2012 at 10:05 AM
Edited Sep 6, 2012 at 10:12 AM

There is actually an even easier way to click the OK button from a javascript alert window:

bWin.PerformDialogAction(BrowserDialogAction.Ok);