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

  • SEARCH
  • Home
  • 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 7441093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:57:25+00:00 2026-05-29T10:57:25+00:00

I am facing an issue in automating a web application using selenium web driver.

  • 0

I am facing an issue in automating a web application using selenium web driver.

The webpage has a button which when clicked opens a new window. When I use the following code, it throws OpenQA.Selenium.NoSuchWindowException: No window found

WebDriver.FindElement(By.Id("id of the button that opens new window")).Click();
//Switch to new window
_WebDriver.SwitchTo().Window("new window name");
//Click on button present on the newly opened window
_WebDriver.FindElement(By.Id("id of button present on newly opened window")).Click();

To solve the above issue I add Thread.Sleep(50000); between the button click and SwitchTo statements.

WebDriver.FindElement(By.Id("id of the button that opens new window")).Click();
Thread.Sleep(50000); //wait
//Switch to new window
_WebDriver.SwitchTo().Window("new window name");
//Click on button present on the newly opened window
_WebDriver.FindElement(By.Id("id of button present on newly opened window")).Click();

It solved the issue, but I do not want to use the Thread.Sleep(50000); statement because if the window takes more time to open, code can fail and if window opens quickly then it makes the test slow unnecessarily.

Is there any way to know when the window has opened and then the test can resume its execution?

  • 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-29T10:57:26+00:00Added an answer on May 29, 2026 at 10:57 am

    You need to switch the control to pop-up window before doing any operations in it. By using this you can solve your problem.

    Before opening the popup window get the handle of main window and save it.

    String mwh=driver.getWindowHandle();

    Now try to open the popup window by performing some action:

    driver.findElement(By.xpath("")).click();
    
    Set s=driver.getWindowHandles(); //this method will gives you the handles of all opened windows
    
    Iterator ite=s.iterator();
    
    while(ite.hasNext())
    {
        String popupHandle=ite.next().toString();
        if(!popupHandle.contains(mwh))
        {
            driver.switchTo().window(popupHandle);
            /**/here you can perform operation in pop-up window**
            //After finished your operation in pop-up just select the main window again
            driver.switchTo().window(mwh);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my web application i am facing a issue after making it live. i
I am new to MVC and facing one issue. I have a xml file
I am using Appweb server (mini http server) and facing an issue while opening
I'm working on a project which uses user authentication. I'm facing a issue with
i am doing a database design using EAV. I am facing an issue when
I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls
I'm facing a frustrating issue. I have an application where the scroll wheel doesn't
I am facing issue with proper date retrieval using date formatter.I have saved the
Im facing an issue which I believe to be VAO-dependant, but Im not sure..
I am facing an issue while streaming PDF file on a Java EE web

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.