java - How to write a code that will execute after each step is executed -


the application working throws lot of unexpected alerts . wanted implement way catch these through common method isalert present .

but how call isalertpresnt each step in webdrriver , can me here ?

typically method :-

public void checkalert() {     try {         webdriverwait wait = new webdriverwait(driver, 2);         wait.until(expectedconditions.alertispresent());         alert alert = driver.switchto().alert();         alert.accept();     } catch (exception e) {         //exception handling     } } 

the issue how call before every step ? know make code slow badly want implemented .

i looking executes after each command\step in test .is possible ?

currently calling method in expected scenarios try catch.

webdriver has webdrivereventlistener listener trying exactly. implementing listener , registering driver - can checkalert method called behind scenes before/after every action perform using webdriver.

take @ example.

http://toolsqa.com/selenium-webdriver/event-listener/


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -