Do you have questions ? We got the answers!

Ask a question:

1
Unable to close the pop up modal (Note : Pop up modal is application related and not from the browser)

Open 1 Answers 23 Views
The code should create the task modal and should close the modal. Am not getting any exception or error but the modal window is not closing. Below is the code:

public void addTask() throws Exception {

            driver.findElement(By.xpath("//*[@id=\"my-workspace-box\"]/ul/li[1]/a[1]")).click();
            driver.findElement(By.id("form-group")).click();
            driver.findElement(By.xpath("//*[@id=\"admin-modal\"]/ul/li[2]/a/span[2]/span[1]")).click();
            driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
            
            driver.findElement(By.id("form-task_name")).sendKeys("test");;
            
            WebElement titleField =  driver.findElement(By.id("form-task_name"));
            
            //driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//*[@id=\"admin-modal\"]/div[2]/div/div[2]/div/div/form/div[9]/button")).click();
   
            if(titleField.getAttribute("value").isEmpty()) {
                System.out.println("Please enter Title for the task");
            }
            else
            {
                System.out.println("Task has been created");
            }
            
            driver.findElement(By.className("close")).click(); -> This line is not working
            }

1 Answer

0
If the pop up is not part of your browser window, it can not be handled by selenium. As selenium is totally developed using JavaScript. JavaScript can not handle such pop ups as it's not a part of browser. So, selenium will not be able to work with it.

 

You should start using third party tools like Sikuli or AutoIT.
answered Sep 13 by anonymous
1Comments
commented Sep 14 by Priyanka91 (91 points)
Thank you for the reply!

Top Contributors

  • 4970 pointsstbadmin

    34 questions 454 answers218 comments

  • 433 pointsSunilBhaskar

    41 questions 15 answers32 comments

  • 425 pointsMehedi

    36 questions 3 answers14 comments

  • 363 pointssumitkumarwatts

    0 questions 13 answers0 comments

  • 354 pointsSoft Tester

    43 questions 0 answers4 comments

  • 327 pointsKeeshaGolden

    0 questions 17 answers2 comments

  • 322 pointsVipul Sharma

    44 questions 0 answers24 comments

  • 310 pointsvysh.sharma

    25 questions 0 answers0 comments

  • 267 pointsOnkar_Nimje

    33 questions 15 answers15 comments

  • 258 pointsVanitha

    26 questions 0 answers6 comments

...