I’m using selenium webdriver 2.0 java api to run some tests in my company. I’m doing it at free will and have no heavy knowledge about automation so part my ignorance.
I would like to know how can I retrieve the result from a “@test” method in case I would like to log results of tests to file.
Say I have this test case, how will I return a result for it as a boolean?
@Test
public void like(){
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.className("feed-item-ph")));
WebElement like = driver.findElement(By.cssSelector("a.action-block-a.action-like"));
like.click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("registration-book")));
driver.quit();
}
Well, you can’t. Either it is a Testcase, or it is a regular function. Since the Testdriver decides how to call your test case and it doesn’t know what to do with the boolean anyway, this doesn’t make any sense.
The most simple way to make it work, would be to write a function that returns a boolean and just to call that function inside a testcase. Then you can easily gether all the information you want.