seleniumwebdriverautotest

Selenium webdriver doesn't show error about noutfounding element


I try to find text on the page driver.findElement(By.xpath("//label[contains(text(),'Some text')]"));

I know that text not displayed in the page. But system accepts test as Successed.

Why System doesn't show Error about NoSuchElementException


Solution

  • You do not use the result of driver.findElement(By.xpath("//label[contains(text(),'Some text')]")); like not clicking it driver.findElement(By.xpath("//label[contains(text(),'Some text')]")).click(); or something else.
    Calling the driver.findElement(By.xpath("//label[contains(text(),'Some text')]")); returns null but you do not assert or verify the result in any way.