I have a question that I try to resolve. I have a screen in my webpage, that open a dialog box to upload a file. I managed to select the file, However the dialog box not closed, and stayed open. So I can not proceed with the other things on screen. I want to close the dialog box. I try to close the driver and it is closed the web page. I try to create a function of all the windows opened and it is not find the dialog box. How can I close this dialog box? this is what I done that not worked since it is not recognized the dialog box. (says only one window is opened) The problem is that in the devtool I do not find the locator that closed this dialog box, since I can not inspect it, can someone advise just how to close this? since the browser is stuck,
Thread.sleep(8000); Set <String> w = deiver2.getWindowHandles(); // create set of all windows deiver2.switchTo() .activeElement(); System.out.println("Window title: "+ deiver2.getTitle()); deiver2.findElement(By.xpath("//input[@type='file']")) .sendKeys( "X:\\AutomationFiles\\yoyoy.pdf"); for (String h: w){ deiver2.switchTo().window(h); String s= deiver2.getTitle(); System.out.println("Window title: "+ deiver2.getTitle()); if(s.equalsIgnoreCase("Open")){ System.out.println("Window title to be closed: "+ deiver2.getTitle()); deiver2.close(); } } deiver2.switchTo().window(base); System.out.println("END");