Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:52:59+00:00 2026-05-27T06:52:59+00:00

I am currently assisting in a proof of concept using Selenium 2 / WebDriver

  • 0

I am currently assisting in a proof of concept using Selenium 2 / WebDriver with C# against an ASP.NET MVC application using the InternetExplorerDriver.

The application uses a standard pattern for notifying users that a record has saved. This works by settings TempData to include “Record saved successefully”, and if TempData is present in the View, the view will alert the message.

Whilst working on Selenium tests for this functionality, we are receiving inconstitant behaviour from the below C# / Selenium test code:

        _driver.Navigate().GoToUrl(_baseUrl + "/Amraam/List");
        _driver.FindElement(By.LinkText("Create New")).Click();

        _driver.FindElement(By.Id("txtAmraamSerialNumber")).SendKeys("CC12345");

        var selectElement = new SelectElement(_driver.FindElement(By.Id("LocationId")));
        selectElement.SelectByText("Tamworth");
        _driver.FindElement(By.Id("btnSave")).Click();
        var wait = new WebDriverWait(_driver, defaultTimeout);
        IAlert alert = wait.Until(drv => drv.SwitchTo().Alert());
        _alertText = alert.Text;

        alert.Accept();
        Assert.That(_alertText, Is.EqualTo("Record successfully saved")); 

Approximately 50% of the time, Selinium will fail with a

OpenQA.Selenium.NoAlertPresentException : No alert is active

I struggle to find an exact way to replicate the issue, and worry regarding the inconsistency aspect. If it failed consistently, then we could debug and track the problem down.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:53:00+00:00Added an answer on May 27, 2026 at 6:53 am

    The handling of alerts and prompts within Selenium 2 is pretty new and is still under active development.
    Your failures are probably due to timing, so I would suggest writing a wrapper method around the call to SwitchTo().Alert() so that you catch the OpenQA.Selenium.NoAlertPresentException and ignore it until the timeout expires.

    Something as simple as this should work:

    private IAlert AlertIsPresent(IWebDriver drv)
    {
        try
        {
            // Attempt to switch to an alert
            return drv.SwitchTo().Alert();
        }
        catch (OpenQA.Selenium.NoAlertPresentException)
        {
            // We ignore this execption, as it means there is no alert present...yet.
            return null;
        }
    
        // Other exceptions will be ignored and up the stack
    }
    

    This line

    IAlert alert = wait.Until(drv => drv.SwitchTo().Alert());
    

    would then become

    IAlert alert = wait.Until(drv => AlertIsPresent(drv));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using asp.net built-in membership and role provider. In my application Admin Create
I'm currently developing a multi-tiered application, using MVC3 and Spring.NET all of which is
I am currently assessing application scripting language candidates for hosting within a .Net application
I am currently validating my JavaScript against JSLint and making progress on, it's assisting
I am currently developing an asp.net web app. I have a class which is
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
I am currently hard coding the authorized roles in the filter in my MVC
I am currently writing unit tests for an application near completion (before management looks
I'm currently translating an application from actionscript-3 to Java code and got stuck with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.