I wrote a simple Fitnesse tes which works fine. Today I found that there is a difference in the error which shown by the fitnesse generated output page (NoSuchElementException) and the output shown by the console (java.lang.Exception). Any idea what causes this and how can I make sure the correct error is shown by the console as well?
The situation is like this.
In my content file I have a line like:
|check|field exists|testknop|true|
The corresponding method in my fixture looks like:
public boolean fieldExists(String fieldName) {
// Als het element niet gevonden kan worden treed eer een exception op dus assert is niet
// nodig
driver.findElement(By.id(fieldName));
// sluit driver weer af
driver.quit();
return false;
}
Now the generated fitnesse report the line is marked yellow, containing a stacktrace with a selenium NoSuchElementException.
When I run it from maven I get a generic java.lang.Exception
Thanks
I managed to find a solution that works for me.
The porblem was that the driver.findElement(By.id(fieldName));
causes an exception sometimes.
When I change the test and code as I posted below it works for mee.
|check|field exists|testknop|inloggen gelukt|
public String fieldExists(String fieldName) {
// Als het element niet gevonden kan worden treed eer een exception op dus assert is niet
// nodig
try {
driver.findElement(By.id(fieldName));
} catch (NoSuchElementException e) {
return "Inloggen mislukt";
}
// sluit driver weer af
driver.quit();
return "inloggen gelukt";
}