asp.net - Is this the right way to handle javascript alert dialogs using WebDriver? -



asp.net - Is this the right way to handle javascript alert dialogs using WebDriver? -

it seems in asp.net webdriver api, executing next when there no javascript alert nowadays results in exception:

browser.switchto().alert();

ie , ff both throw webdriverexception, chrome throws invalidoperationexception.

so far, code seems work:

try { var alert = browser.switchto().alert(); if (alert != null) alert.dismiss(); } grab (webdriverexception) { // alert not nowadays in ie or ff } grab (invalidoperationexception) { // alert not nowadays in chrome }

is there way check alert dialog present, without having grab exception?

the actual reply here no, must grab exception. logic behind design of api should aware of browser state expect. if expect alert appear, should able utilize switchto() switch , handle it. if expect alert appear, , utilize switchto() , not present, exceptional condition, , exception thrown. normal (non-exceptional) case not expect alert, , there no corresponding method alert not beingness displayed. incidentally, same logic employed findelement(). can argue wrong logic beingness employed api designers, way current api implemented.

asp.net exception webdriver javascript

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -