If you lot involve to generate warning during your software bear witness instance execution in addition to thus you lot tin utilisation coffee script Executor inward selenium webdriver software testing tool. Java Script Executor is really helpful interface of selenium webdriver because using it nosotros tin execute whatever coffee script. I intend manual alert generation inward webdriver test is required alone inward rare instance but main role of this postal service is to explore Java Script Executor. You tin sentiment to a greater extent than examples of JavascriptExecutor on THIS LINK.
If you lot remember, nosotros tin generate warning inward selenium IDE software testing tool likewise using "runScript" command. THIS POST volition depict you lot how to generate warning inward selenium IDE software testing tool using "runScript" ascendence amongst example.
Now allow me depict you lot how to generate warning inward selenium webdriver software automation if required during bear witness instance execution of your software spider web application.
Example three : JavascriptExecutor to generate warning inward selenium webdriver
@Test populace void bear witness () throws InterruptedException { //Generating Alert Using Javascript Executor JavascriptExecutor javascript = (JavascriptExecutor) driver; javascript.executeScript("alert('Test Case Execution Is started Now..');"); Thread.sleep(2000); driver.switchTo().alert().accept(); }
In inward a higher house example, Java Script Executor volition precisely execute the javascript in addition to generate alert. You tin your ain warning text inward it. Try it inward your ain software application bear witness if required.