is it a prompt dialog, if yes, you can switch to the alert and accept or cancel it.
If it is a modal window, you main window will be frozen and you web driver call method will never return. so, you can't move to the next line and not able to click ok or cancel button. one workaround is inject some javascript method to override the showModalDialog method and change its behavior to open a normal window, but this way has some limitation, if your app requires some result return back from the javascript showModalDialog method, it does not work. below is the code, you can try: