I am writing a Selenium test for a web application, and it seems that there are several instances of an internal server error in the Internal Server Error application, the application displays a user error page, and the error identifier is displayed to the user to continue working with the technical team, in case the user encounters with her.
This makes it difficult to debug test failures during the execution of Selenium. I was thinking of using some kind of mechanism to poll the page with each step performed in the test to determine if there was any instance of an internal server error. And so when I came across a Junit rule and thought about writing a custom annotation for it, some thing like -
public class SelTestCase { protected WebDriver driver; @Before public void startDriver() { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://www.google.com/"); } @After public void closeDriver() { driver.quit(); } } public class GoogleSearchTest extends SelTestCase { @Rule PageChecker pageChecker = new PageChecker(); @Test @CheckPage public void testGoogleSearch() { GoogleHomePage googleHomePage = PageFactory.initElements(driver, GoogleHomePage.class); googleHomePage.searchGoogle("Selenium HQ"); assert driver.getPageSource().contains("seleniumhq") : "Selenium headquarter search failed"; } }
SelTestCase class creates an instance of WebDriver to run the test, but the PageChecker class -
public class PageChecker extends SelTestCase { @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface CheckPage {
Here's what I'm stuck with, how can I continue with CheckPage annotations?
source share