Code example for AssertionFailedError

0
	@Test 
	public void shouldUpdateOutputPanel() { 
		WebElement panel = getPanel();
		try { 
			checkImgExists(panel);
			throw new AssertionFailedError(
					"Image is on the page but it should not be!"); 
		} catch (NoSuchElementException e) {
			// everything is ok 
		} 
 
		findElementById("form:showButton").click(); 
 
		panel = getPanel();
		checkImgExists(panel);
	} 
 
	private void checkImgExists(WebElement panel) {
		panel.findElement(By.tagName("img"));
	}