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

Chrome dialog handler issues.

4 Answers 67 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Zach
Top achievements
Rank 1
Zach asked on 15 Dec 2014, 05:13 PM
Hello Telerik Team!

I have been having difficulties handling a simple dialog box in chrome.
The alert is handled properly in IE, FireFox, and Safari.

This is the code I'm using to handle everything. I've tried using an 'AlertDialog' for chrome but that doesn't seem to work either.

iFrame.RefreshDomTree();
man.DialogMonitor.AddDialog(new ConfirmDialog(ab, DialogButton.OK));
man.DialogMonitor.Start();
iFrame.Actions.Click(iFrame.Find.ById("btnDelete"));

http://imgur.com/F2VTeHp

Any ideas?

4 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 18 Dec 2014, 04:31 PM
Hello Zach,

Which version of the testing framework are you using? I confirmed this is working as expected in our latest release, 2014.4.1211. I'd also like you to try running the following test. This will tell us if the problem is specific to your application or your testing environment:

using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.TestTemplates;
using ArtOfTest.WebAii.Win32.Dialogs;
 
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace TestExamplesProject
{
    /// <summary>
    /// Summary description for Handle_Confirm_DialogUnitTest
    /// </summary>
    [TestClass]
    public class Handle_Confirm_DialogUnitTest : BaseTest
    {
 
        #region [Setup / TearDown]
 
        private TestContext testContextInstance = null;
        /// <summary>
        ///Gets or sets the VS test context which provides
        ///information about and functionality for the
        ///current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
 
 
        //Use ClassInitialize to run code before running the first test in the class
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
        }
 
        private Pages _pages;
 
        public Pages Pages
        {
            get
            {
                if (_pages == null)
                {
                    _pages = new Pages(Manager.Current);
                }
                return _pages;
            }
        }
 
 
        // Use TestInitialize to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
            #region WebAii Initialization
 
            // Initializes WebAii manager to be used by the test case.
            // If a WebAii configuration section exists, settings will be
            // loaded from it. Otherwise, will create a default settings
            // object with system defaults.
            //
            // Note: We are passing in a delegate to the VisualStudio
            // testContext.WriteLine() method in addition to the Visual Studio
            // TestLogs directory as our log location. This way any logging
            // done from WebAii (i.e. Manager.Log.WriteLine()) is
            // automatically logged to the VisualStudio test log and
            // the WebAii log file is placed in the same location as VS logs.
            //
            // If you do not care about unifying the log, then you can simply
            // initialize the test by calling Initialize() with no parameters;
            // that will cause the log location to be picked up from the config
            // file if it exists or will use the default system settings (C:\WebAiiLog\)
            // You can also use Initialize(LogLocation) to set a specific log
            // location for this test.
 
            // Pass in 'true' to recycle the browser between test methods
            Initialize(false, this.TestContext.TestLogsDir, new TestContextWriteLine(this.TestContext.WriteLine));
 
            // If you need to override any other settings coming from the
            // config section you can comment the 'Initialize' line above and instead
            // use the following:
 
            /*
 
            // This will get a new Settings object. If a configuration
            // section exists, then settings from that section will be
            // loaded
 
            Settings settings = GetSettings();
 
            // Override the settings you want. For example:
            settings.Web.DefaultBrowser = BrowserType.FireFox;
 
            // Now call Initialize again with your updated settings object
            Initialize(settings, new TestContextWriteLine(this.TestContext.WriteLine));
 
            */
 
            // Set the current test method. This is needed for WebAii to discover
            // its custom TestAttributes set on methods and classes.
            // This method should always exist in [TestInitialize()] method.
            SetTestMethod(this, (string)TestContext.Properties["TestName"]);
 
            #endregion
 
            //
            // Place any additional initialization here
            //
 
        }
 
        // Use TestCleanup to run code after each test has run
        [TestCleanup()]
        public void MyTestCleanup()
        {
 
            //
            // Place any additional cleanup here
            //
 
            #region WebAii CleanUp
 
            // Shuts down WebAii manager and closes all browsers currently running
            // after each test. This call is ignored if recycleBrowser is set
            this.CleanUp();
 
            #endregion
        }
 
        //Use ClassCleanup to run code after all tests in a class have run
        [ClassCleanup()]
        public static void MyClassCleanup()
        {
            // This will shut down all browsers if
            // recycleBrowser is turned on. Else
            // will do nothing.
            ShutDown();
        }
 
        #endregion
 
        [TestMethod()]
        public void Handle_Confirm_Dialog()
        {
            // Launch an instance of the browser
            Manager.LaunchNewBrowser();
 
            // Navigate to : 'http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm'
            ActiveBrowser.NavigateTo("http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm", true);
 
            // Coded Step From Test
            ConfirmDialog dlg = ConfirmDialog.CreateConfirmDialog(ActiveBrowser, DialogButton.OK);
            Manager.DialogMonitor.AddDialog(dlg);
 
            // Click 'TryItButtonTag0'
            ActiveBrowser.Frames["view"].Find.ByExpression<HtmlButton>("TagIndex=button:0").Click(false);
            //Pages.TryitEditorV190.FrameIframeResult.TryItButtonTag0.Click(false);
 
            dlg.WaitUntilHandled();
 
            System.Threading.Thread.Sleep(5000);
        }
    }
}



Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Zach
Top achievements
Rank 1
answered on 18 Dec 2014, 04:57 PM
I got your test project up and running, and it works for IE.

In FireFox, it pushes the OK button, then crashes.
In Safari, I never see the conf. box appear and the page says  "You pressed Cancel!"
In Chrome the conf. box appears, nothing happens for about 20 seconds, then the program crashes.

I currently have version 2014.3.903.0 of the testing framework.
Where can I download the newest version?
0
Zach
Top achievements
Rank 1
answered on 18 Dec 2014, 04:59 PM
Ignore my last question, I'm currently updating to the newest version of the framework.
0
Cody
Telerik team
answered on 23 Dec 2014, 01:36 AM
Hi,

Sure. Let me know if you need further assistance.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Zach
Top achievements
Rank 1
Answers by
Cody
Telerik team
Zach
Top achievements
Rank 1
Share this question
or