way to do it is delegate the click action to javascript timeout method, it means the click action does not invoke showModalDialog immediately, instead of it, it will ask a javascript timeout method to do it. with it, your web driver will no longer be blocked by the modal window. codes are below:
WebElement webElement = //find your element here
String shortName = "click";
String event = "onclick";
String eventScript = "if(watp_watp_target == null || watp_watp_target == 'undefined'){return;} try{if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('"+ shortName + "', true, false); watp_watp_target.dispatchEvent(evObj);}
else if(document.createEventObject)
{ watp_watp_target.fireEvent('"+ event + "');}}catch(e){}";
String setTimeoutScript = "var watp_watp_target=arguments[0];setTimeout(function(){"+eventScript+"},100)";
WebDriver webDriver = ((WebDriverWrapper) context.getWebDriver()).getWebDriver();
JavascriptExecutor js = (JavascriptExecutor) webDriver;
js.executeScript(setTimeoutScript, webElement);
Above codes will be executed when you want to click the element by web driver. Then, you can switch to the new opened modal window and continue your test.
Best Regards,
--david