Generating HTML results for Selenium RC scripts

Here is an example of Google search and the results are saved as a HTML file: Code for GoogleSearch.cs file: using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Microsoft.VisualStudio.TestTools.UnitTesting; using Selenium; using System.Diagnostics; namespace SeleniumTests { [TestFixture] public class GoogleSearch { private ISelenium selenium; private StringBuilder verificationErrors; [SetUp] public void SetupTest() { selenium = […]

Selenium captureEntirePageScreenshot

Using selenium you can capture the screen shot of the pages when running the selenium script. This is useful when you want to capture the screen shot of the page where you have a failure/ error. selenium.CaptureEntirePageScreenshot(“C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\test.png”, “”); captureEntirePageScreenshot(filename, kwargs) Arguments: * filename – the path to the file to […]

Getting the Browser details in Selenium

There are times when you would like to get the browser details when running the selenium scripts. Here is the selenium script that you can use to to get browser details. String a = selenium.GetEval(“navigator.appCodeName”); Console.WriteLine(a); String b = selenium.GetEval(“navigator.appName”); Console.WriteLine(b); String c = selenium.GetEval(“navigator.appVersion”); Console.WriteLine(c); String d = selenium.GetEval(“navigator.cookieEnabled”); Console.WriteLine(d); String e = selenium.GetEval(“navigator.platform”); […]

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:- ” + […]

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) { selenium.Click(link); selenium.WaitForPageToLoad(“30000″); } Submitted by: Horgan Barry [ad#PostAD]

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 […]