Selenium – Driver.quit () does not close your browser window

I have a framework and I am running my test; any error will cause the WebDriver instance to call something like the handleexception method, I call the driver.quit() method. I think driver.quit () Tried to close the browser but then the browser throws a dialog box with a message that you want to leave this page-this is not processed. No exception is thrown, but the remaining test cases do not work when starting the browser , But there is an exception thrown in the modal dialog box, which is understandable.
How can I solve this problem?

Handleexception method:

Driver.getFailedTestCaseNames().add(this.getTestcaseName());
String failedStepStr = " ";
failedStepStr = "Test Case failed while executing step "+ stepNo +"-Method Name:" + t.getMethodnm() + ", Field Name:" + t.getField() + ", Field value: "+ t.getValue();

LOG.error("Test Case Name:" + testcaseName + "failed while executing step" + stepNo + "-Method Name:" + t.getMethodnm() + ", Field Name:" + t.getField() + ", Field value:"
+ t.getValue() + ExceptionUtils.getStackTrace(th));

CaptureScreenshot objCapturScreenshot = new CaptureScreenshot();

objCapturScreenshot.caputureImage(testcaseName);
System.out.println(" in handle exception");
driver.quit();

System.out.println("Test case failed: "+this.getTestcaseName());
throw new TestAutomationException(failedStepStr, th);

Log of guilty test case Yes:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.35.0', revision:'c916b9d', time: '2013 -08-12 15:42:01'
System info: os.name:'Windows 7', os.arch:'x86', os.version: '6.1', java.version: '1.7.0_11 '
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver .execute(RemoteWebDriver.java:569)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:423)
at com.bmc.core.test.domain.TestCase.handleException (TestCase.java:364)
at com.bmc.core.test.domain.TestCase.execute(TestCase.java:136)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect. Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)< br /> at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng. internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java: 768)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner .runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteR unnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1022)
at org.testng.TestNG.privateMain(TestNG .java:1325)
at org.testng.TestNG.main(TestNG.java:1294)
Caused by: org.openqa.selenium.WebDriverException: java.net.SocketTimeoutException: Read timed out
Build info: version: '2.35.0', revision:'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name:'Windows 7', os .arch:'x86', os.version: '6.1', java.version: '1.7.0_11'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service .DriverCommandExecutor.execute(DriverCommandExecutor.java:75)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:5 27)
... 26 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java. net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:92)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:62)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
at org.apache.http.impl.AbstractHttpClient Connection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
at org.apache.http.impl.conn. AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
at org.apache.http.protocol.HttpRequestExecutor.execute( HttpRequestExecutor.java:127)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:712)
at org.apache.http.impl.client.DefaultRequestDirector.execute( DefaultRequestDirector.java:517)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor. java:319)
at org.openqa.selenium.remote.H ttpCommandExecutor.execute(HttpCommandExecutor.java:298)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:66)
... 27 more

The log of the subsequent test case is:

com.bmc.core.test.exception.TestAutomationException: Test Case failed while executing step 1-Method Name:waitAndSwitchToWindow,
Field Name:Inquira Information Manager, Field value:20000
at com.bmc.core.test.domain.TestCase.handleException(TestCase.java:400)
at com.bmc.core.test. domain.TestCase.execute(TestCase.java:136)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java .lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMe thod(Invoker.java:702)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng .TestRunner.privateRun(TestRunner.java:768)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)< br /> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run( SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java :1022)
at org.testng.TestNG.privateMain(TestNG.java:1325)
at org.testng.TestNG.main(TestNG.java:1294)
Caused by: java. lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke( Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.bmc.core.test.domain.TestCase.execute(TestCase.java:99)
... 22 more
Caused by: org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.35.0', revision:'c916b9d', time: '2013- 08-12 15:42:01'
Sys tem info: os.name:'Windows 7', os.arch:'x86', os.version: '6.1', java.version: '1.7.0_11'
Session ID: ac1a28e7-2c24-443f- 9c0e-d308645fab2d
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true,
ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss,
version=10, ie.usePerProcessProxy=false, ignoreProtectedModeSettings=false, cssSelectorsEnabled=true, requireWindowFocus=false,
initialBrowserUrl =http://www.localohst:10879/, handlesAlerts=true, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0,
ie.browserCommandLineSwitches=, takesScreenshot=true}]
at sun .reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl .newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium .remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:172)
at org.openqa.selenium.remote.ErrorHandler .throwIfResponseFailed(ErrorHandler.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver .java:569)
at org.openqa.selenium.remote.RemoteWebDriver.getWindowHandles(RemoteWebDriver.java:432)
at com.bmc.core.test.app.Base.waitAndSwitchToWindow(Base.java :278)
... 27 more

After Paul’s suggestion, I came up with this snippet, which is good… It closes all browsers to exit, regardless of whether they throw an alert when closing…

try
{
Set windowIterator = driver.getWindowHandles();
Iterator iter = windowIterator.iterator();
System.out.println(" no of windows to close ="+windowIterator.size());
LOG.debug("no of windows to close ="+windowIterator.size());
int i=0;
while (iter.hasNext())
{
try
{
i++;
System.out.println("lopp value = "+i);
LOG.debug("loop value = "+i);
String windowHandle = iter.next();
driver.switchTo().window(windowHandle);
String windowTitle = driver.getTitle();
System.out.println("title="+driver.getTitle()+"-attempting to close this window");
LOG.debug("title= "+driver.getTitle()+"-attempting to close this window");
driver.close();
Thread.sleep(5000);

while(isAlertPresent())
{
try
{
driver.switchTo().alert(). accept();
System.out.println("alert accepted after close");
LOG.debug("alert accepted after close");
Thread.sleep(5000);< br /> }
catch (Exception e)
{
e.printStackTrace();
LOG.debug("alert loop... inner while --> exception: " +e.getMessage());
}
}
System.out.println("title="+windowTitle+"-window closed");
LOG.debug(" title="+windowTitle+"-window closed");
}
catch (Exception e)
{
e.printStackTrace();
LOG.debug(" window loop... outer while --> e xception: "+e.getMessage());
}
}
Thread.sleep(5000);
while(isAlertPresent())
{
driver.switchTo().alert().accept();
System.out.println("alert accepted before quit");
LOG.debug("alert accepted before quit");< br /> Thread.sleep(5000);
}
}
catch (Exception e)
{
e.printStackTrace();
LOG. debug("outer exception: "+e.getMessage());
}

driver.quit();
System.out.println("quitting the driver instance" );
LOG.debug("quitting the driver instance");
//======================== ================================================= ======

I have a framework and I am running my tests; any error will cause the WebDriver instance to call something similar to the handleexception method, and I call the driver. quit() method. I think driver.quit() tries to close the browser but then the browser throws a dialog box with a message that you want to leave the page-this is not processed. No exception is thrown, but the rest The test case does not work when starting the browser, but it throws an exception in the modal dialog box, which is understandable.
How can I solve this problem?

Handleexception method:

Driver.getFailedTestCaseNames().add(this.getTestcaseName());
String failedStepStr = " ";
failedStepStr = "Test Case failed while executing step "+ stepNo +"-Method Name:" + t.getMethodnm() + ", Field Name:" + t.getField() + ", Field value: "+ t.getValue();

LOG.error("Test Case Name:" + testcaseName + "failed while executing step" + stepNo + "-Method Name:" + t.getMethodnm() + ", Field Name:" + t.getField() + ", Field value:"
+ t.getValue() + ExceptionUtils.getStackTrace(th));

CaptureScreenshot objCapturScreenshot = new CaptureScreenshot();

objCapturScreenshot.caputureImage(testcaseName);
System.out.println(" in handle exception");
driver.quit();

System.out.println("Test case failed: "+this.getTestcaseName());
throw new TestAutomationException(failedStepStr, th);

Log of guilty test case Yes:

o rg.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.35.0', revision:'c916b9d', time: '2013-08- 12 15:42:01'
System info: os.name:'Windows 7', os.arch:'x86', os.version: '6.1', java.version: '1.7.0_11'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.execute( RemoteWebDriver.java:569)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:423)
at com.bmc.core.test.domain.TestCase.handleException(TestCase. java:364)
at com.bmc.core.test.domain.TestCase.execute(TestCase.java:136)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method .invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng.internal .TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:768 )
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner. runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerW orker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1022)
at org.testng.TestNG.privateMain(TestNG .java:1325)
at org.testng.TestNG.main(TestNG.java:1294)
Caused by: org.openqa.selenium.WebDriverException: java.net.SocketTimeoutException: Read timed out
Build info: version: '2.35.0', revision:'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name:'Windows 7', os .arch:'x86', os.version: '6.1', java.version: '1.7.0_11'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service .DriverCommandExecutor.execute(DriverCommandExecutor.java:75)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 26 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream. read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:92)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:62)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
at org.apache.http.impl.AbstractHttpClientConnec tion.receiveResponseHeader(AbstractHttpClientConnection.java:289)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
at org.apache.http.impl.conn. AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
at org.apache.http.protocol.HttpRequestExecutor.execute( HttpRequestExecutor.java:127)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:712)
at org.apache.http.impl.client.DefaultRequestDirector.execute( DefaultRequestDirector.java:517)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor. java:319)
at org.openqa.selenium.remote.HttpCom mandExecutor.execute(HttpCommandExecutor.java:298)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:66)
... 27 more

The log of the subsequent test case is:

com.bmc.core.test.exception.TestAutomationException: Test Case failed while executing step 1-Method Name:waitAndSwitchToWindow,
Field Name:Inquira Information Manager, Field value:20000
at com.bmc.core.test.domain.TestCase.handleException(TestCase.java:400)
at com.bmc.core.test. domain.TestCase.execute(TestCase.java:136)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java .lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invo ker.java:702)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner .privateRun(TestRunner.java:768)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner. java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org .testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1022 )
at org.testng.TestNG.privateMain(TestNG.java:1325)
at org.testng.TestNG.main(TestNG.java:1294)
Caused by: java.lang. reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source )
at java.lang.reflect.Method.invoke(Unknown Source)
at com.bmc.core.test.domain.TestCase.execute(TestCase.java:99)
.. . 22 more
Caused by: org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.35.0', revision:'c916b9d', time: '2013-08- 12 15:42:01'
System info: os.name:'Windows 7', os.arch:'x86', os.version: '6.1', java.version: '1.7.0_11'
Session ID: ac1a28e7-2c24-443f-9c0e-d308645fab2d
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover ie=true,
.ensureCleanSession =false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss,
version=10, ie.usePerProcessProxy=false, ignoreProtectedModeSettings=false, cssSelectorsEnabled=true, requireWindowFocus=false,
initialBrowserUrl=http: //www.localohst:10879/, handlesAlerts=true, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0,
ie.browserCommandLineSwitches=, takesScreenshot=true}]
at sun.reflect. NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium. remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:172)
at org.openqa.selenium.remote.ErrorHandler. throwIfResponseFailed(ErrorHandler.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver. java:569)
at org.openqa.selenium.remote.RemoteWebDriver.getWindowHandles(RemoteWebDriver.java:432)
at com.bmc.core.test.app.Base.waitAndSwitchToWindow(Base.java: 278)
... 27 more

After Paul’s suggestion, I put forward this snippet, which is good…. It closes all browsing The device exits, regardless of whether they throw an alert when shutting down…

< p>

try
{
Set windowIterator = driver.getWindowHandles();
Iterator iter = windowIterator.iterator();
System.out.println("no of windows to close ="+windowIterator.size());
LOG.debug("no of windows to close ="+windowIterator.size());
int i=0;
while (iter.hasNext())
{
try
{
i++;
System.out.println(" lopp value = "+i);
LOG.debug("loop value = "+i);
String windowHandle = iter.next();
driver.switchTo().window( windowHandle);
String windowTitle = driver.getTitle();
System.out.println("title="+driver.getTitle()+"-attempting to close this window");
LOG.debug("title="+driver.getTitle()+"-attempting to close this window");
driver.close();
Thread.sleep(5000);

while(isAl ertPresent())
{
try
{
driver.switchTo().alert().accept();
System.out.println("alert accepted after close");
LOG.debug("alert accepted after close");
Thread.sleep(5000);
}
catch (Exception e)
{
e.printStackTrace();
LOG.debug("alert loop... inner while --> exception: "+e.getMessage());
}
}
System.out.println("title="+windowTitle+"-window closed");
LOG.debug("title="+windowTitle+"-window closed");
}
catch (Exception e)
{
e.printStackTrace();
LOG.debug("window loop... outer while --> exception: "+e.getMessage ());
}
}
Thread.sleep(5000);
while(isAlertPresent())
{
driver.switchTo().alert().accept();
System.out.println( "alert accepted before quit");
LOG.debug("alert accepted before quit");
Thread.sleep(5000);
}
}
catch (Exception e)
{
e.printStackTrace();
LOG.debug("outer exception: "+e.getMessage());
}
< br /> driver.quit();
System.out.println("quitting the driver instance");
LOG.debug("quitting the driver instance");
//= ================================================== ===============================

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4305 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.