Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Modal dialog present (UnexpectedAlertOpen) issue in IE (Similar issue like 3360) #5158

Closed
lukeis opened this issue Mar 4, 2016 · 10 comments
Closed

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 5158

Hi,
This is pavan,i would like to say thanks for providing great guidance for the people
who are working on selenium like me.
Issue: 
 i am also encountering the same problem but i could not get the proper solution to
resolve this issue

Actually over the period of 2 months we are developing automation application using
selenium webdriver and it is running fine and we ran some cycles of regression suites,but
now suddenly we are getting the following error Modal dialog present (UnexpectedAlertOpen)but
i have verified,there is no model dialog box opened and also there is no IE dev tool
opened but still i am getting this issue.
please find the attachment for reference

Configuration details:
IE driver 2.25.2.0
Windows7(32bit)
IE8

we are using C# with selenium

Please help me asap.


Reported by mailtopavan1987 on 2013-02-13 12:19:04

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Selenium automatically closes unhandled modal diaplogs (and throws an exception). You
can disable closing such diaplog you can set capability unexpectedAlertBehaviour to
"ignore" (it is "dismiss" by default). In this case an exception will be thrown, but
the dialog will not be closed and you'll be able to see it.

P.S. By the way, the issue has no attachment you mentioned)
P.P.S. Why do yo use 2.25 ? The latest version is 2.29 at the moment

Reported by barancev on 2013-02-13 16:34:25

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi Can you just make me understand that how to set capability unexpectedAlertBehaviour
to "ignore"

and one more importnat ponit is that this error is occuring only on the machine which
has mcafee site adviser in rest of all machines scripts are running as expected

i did arrach the doc but no idea why you could not get it.

again i am attaching the same here, please find the same

Reported by mailtopavan1987 on 2013-02-14 06:44:27


- _Attachment: [Modaldialog.doc](https://storage.googleapis.com/google-code-attachments/selenium/issue-5158/comment-2/Modaldialog.doc)_

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

namespace Permedion.Automation.Core
{
    #region Import Namespaces
    using System;
    using System.Configuration;
    using System.IO;
    using System.Xml;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Firefox;
    using OpenQA.Selenium.IE;
    using OpenQA.Selenium.Remote;
    using OpenQA.Selenium.UnhandledAlertException;
    using OpenQA.Selenium.Safari;
    using System.Windows.Automation;
    using System.Threading;
    #endregion

    /// <summary>
    /// Public class to implement the functionalities related to AutomationBase.
    /// </summary>
    public class AutomationBase
    {
        #region Properties
        /// <summary>
        /// Gets or sets the value of the CurrentWebDriver of type OpenQA.Selenium.IWebDriver.
        /// </summary>
        public static IWebDriver CurrentWebDriver
        {
            get;
            set;
        }
        private Thread autoThread;

        //Declaring global variables
        public static string timerValue;
        public static int iterationCount =1;
        public static string browserType;
        #endregion


        #region Methods
        /// <summary>
        /// Public method which includes logic related to StartBrowser.
        /// </summary>
        /// <returns>Returns object of type OpenQA.Selenium.IWebDriver.</returns>
        public static IWebDriver StartBrowser()
        {
            if (iterationCount <= 1)
            {
              timerValue = (DateTime.Now).ToString().Replace(":", ".");
              iterationCount = iterationCount + 1;
            }

            browserType = ConfigurationManager.AppSettings.Get("Browser");
            switch (browserType.ToUpper())
            {
                case "IE":                      
                     InternetExplorerOptions options = new InternetExplorerOptions();
                     options.IntroduceInstabilityByIgnoringProtectedModeSettings =
true;
                     options.IgnoreZoomLevel = true;                     
                     DesiredCapabilities cap = DesiredCapabilities.InternetExplorer();

                     CurrentWebDriver = new InternetExplorerDriver(options);      

                     break;
                case "SAFARI":
                    CurrentWebDriver = new SafariDriver();
                    break;
                case "CHROME":
                    CurrentWebDriver = new ChromeDriver();
                    break;
                case "FF":
                default:
                    FirefoxProfile profile = new FirefoxProfile();
                    profile.AcceptUntrustedCertificates = true;
                    CurrentWebDriver = new FirefoxDriver(profile);
                    break;
            }

            return CurrentWebDriver;
        }

Reported by mailtopavan1987 on 2013-02-14 07:17:16

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Please find the above piece of code ant make me understand where i went worng.

Thanks,
Pavan

Reported by mailtopavan1987 on 2013-02-14 07:18:14

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

As you suggested i had configured the selenium with latest drivers i.e 2.9 but still
i am facing the same issue with diffrent alert message box.

i am not sure how to use capabilities with options, please help me in this since i
am not able to move forward.

the only one diffrence i can see after installing the latest drivers is only change
in alert messgae apart from that nothing is workedout.

   InternetExplorerOptions options = new InternetExplorerOptions();
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                    options.IgnoreZoomLevel = true;
                    DesiredCapabilities ieCapabilities = options.ToCapabilities() as
DesiredCapabilities;
                    ieCapabilities.SetCapability("Ignore",InternetExplorerUnexpectedAlertBehavior.Ignore);
                    CurrentWebDriver = new InternetExplorerDriver(options);   

Reported by mailtopavan1987 on 2013-02-14 11:13:54

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

@mailtopavan1987 With the latest .NET bindings, you should not have to use DesiredCapabilities
directly in most cases. Specifically, you should be able to do the following:

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.IgnoreZoomLevel = true;
options.UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Ignore;
CurrentWebDriver = new InternetExplorerDriver(options);

Incidentally, I would encourage you to not use the IntroduceInstabilityByIgnoringProtectedModeSettings
option if at all possible[1].

[1] http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html

Reported by james.h.evans.jr on 2013-02-14 12:43:40

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Hi,
I tried with all the solutions given by you but still i am getting the same error messgae.

actually there is no opened dialog box to say options.UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Ignore;
but i am wondering why still it is giving such error saying that modal dialog box present
(UnhandledAlertException unhandled by user code).

this is happening since we have installed mcafee-siteadviser patch before that no such
error occured.

is it because of mcafee-siteadiver? if so is there any solution to overcome this?

Reported by mailtopavan1987 on 2013-02-18 06:23:40

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

See also issue 4839

Reported by barancev on 2013-02-18 07:43:59

  • Labels added: Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Since this behavior is only observed where McAfee SiteAdvisor is installed, I'm calling
this a duplicate of #4839.

Reported by james.h.evans.jr on 2013-02-21 16:23:49

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:46

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant