Search⌘ K

Miscellaneous Assertions

Explore how to perform various assertions with Selenium WebDriver in Node.js. Learn to verify image presence, element dimensions, CSS styles, and detect JavaScript errors on web pages. This lesson helps you confidently validate multiple UI aspects and browser console logs during automated testing.

Assert if an image is present

We can assert if an image is present by:

assert(driver.findElement(By.id("next_go")).isDisplayed());

Assert element location and width

We can assert the width and location of an element by:

driver.findElement(By.id("next_go")).getSize().then(function(the_size) {
 
...