i using java, testng , selenium write test. wondering if have assert type can put anything in , if throws exception assert print message like:
assert.something(wait.until(expectedconditions.elementtobeclickable (by.xpath("//button[text()='add representative']"))).click());
i know can use try , catch like:
try{ wait.until(expectedconditions.elementtobeclickable (by.xpath("//button[text()='add representative']"))).click(); }catch(exception e){ assert.assertfalse(true, "this clcik did not work"); }
buy wondering if use in way showed above.
you can use following 2 methods case:
public static void assertnull(java.lang.object object, java.lang.string message)
as click command returns null when element clicked, can assert null , pass message assert want print on failure.
or
public static void assertthrows(assert.throwingrunnable runnable)
this assert function throws exception or not.
you can refer testng assert class , method more details. hope helps.
Comments
Post a Comment