Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
275 views
by Contributing Tester (91 points)
retagged by
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 like 0 dislike
by
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.
by Contributing Tester (91 points)
Thank you for the reply!


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...