WebElement element = driver.findElements(By.id("block-id")); assertNull(element);
??? this code snippet will get a NoSuchEleementException, use the following 2 implementations instead
?
1. make the test expect the very exception
?
@Test(expected = org.openqa.selenium.NoSuchElementException.class) public void haveNoRecommendation() { ... driver.findElement(By.id("block-id")); }?
?
?
2. use findElements instead of findElement
?
public void elementNotExist(String id) { List<WebElement> elements = driver.findElements(By.id(id)); assertTrue(elements.isEmpty()); }
?
?