Generating Alert In Selenium Webdriver using JavascriptExecutor

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.

Copy bellow given @Test method business office of generate warning using javascript instance in addition to supersede it amongst the @Test method business office of instance given on THIS PAGE(Note : @Test method is marked with pink color in that linked page).

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.
More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post