How to verify the image height and width in Selenium

Its now easy to verify the image height and width of an image on a web page using Selenium. Here is the code that verifies if the height of the image is between 595 and 686 px and width is 230 px.

decimal height = selenium.GetElementHeight("//img[@class='heroImageMain']");
decimal width = selenium.GetElementWidth("//img[@class='heroImageMain']");
Console.WriteLine("Hero Image dimensions:- " + width + " x " + height + " pixels.");
if ((height >= 595 && height <= 686) && (width == 230)) { console.writeline(Testcase + "Hero image dimensions are invalid -> " + +width + " x " + height + " pixels.");

Submitted by: Horgan Barry

How did this solution work for you? Do you have a better alternative? Feel free to share your thoughts in comments section below.

Using Array to execute Selenium commands in C#

Here is an example of how you could you an array to execute repetitive selenium commands like selenium.IsElementPresent or selenium.Click.

string[] footerLinks = new string[] { link1, link2, link3, link4, link5, link6, link7, link8, link9};

foreach (string link in footerLinks)

Submitted by: Horgan Barry

An error occurred initializing the VBA libraries – Selenium DataDriven

I use Excel to store the test data and keep all the excel files in a share drive for others to use the same file. I was getting the following error when I was trying to run my selenium C# scripts using NUnit.
System.Runtime.InteropServices.COMException : An error occurred initializing the VBA libraries (112).
The reason for this issue is because of wrong path I specified in my selenium script to open the excel file. Once I changed the path; the selenium script was able to access the test data and exception was resolved.

How to run Unit Tests From Network Drive

When loading a test project from a network drive, Visual Studio builds the projects fine, but when running the test project Visual Studio shows the error:
“Error loading \\\XYZ\Main\XYZ.Framework.Test\bin\Debug\XYZ.Framework.Test.dll: Could not load file or assembly ‘file:///Z:\Projects\XYZ\Main\XYZ.Framework.Test\bin\Debug\XYZ.Framework.Test.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)” in the output window and does not continue.

The solution is to set COMPLUS_LoadFromRemoteSources = 1 in the environment variable.


Selenium-Grid allows the Selenium-RC solution to scale for large test suites or test suites that must be run in multiple environments. With Selenium-Grid, multiple instances of Selenium-RC are running on various operating system and browser configurations. Each of these when launching register with a hub. When tests are sent to the hub they are then redirected to an available Selenium-RC, which will launch the browser and run the test. This allows for running tests in parallel, with the entire test suite theoretically taking only as long to run as the longest individual test.