stuart-d2
9/15/2014 - 5:41 PM

Image Assertions

Image Assertions

// Verify image  
   //storing image in a element var - use chrome dev tool right click extract xpath.  
   Element img = Find.ByXPath("//*[@id='4runner']/td[1]/div/img");
   
   //Asserting that the stored image is of type image
   Assert.IsTrue(image.ElementType == ElementType.Image);
   
    //Asserting that stored image is not equal to null. If object is equal to null, throws AssertionException and displays string message           
    Assert.IsNotNull(image, "Does not exist on the page");
   
   //Alternate null check without using Element image. Tested, works.  
    Assert.IsNotNull(Find.ByAttributes<HtmlImage>("src=~4Runner.png"), "Image is not on the page");