How to take screenshots with Selenium in C#

Very frequently testers will meet a situation where they need to take screenshot of webpage they are testing , either for base line or as a proof of test result. This is same with automated testing . Even though automated test cases have their own of way of publishing test results, it is always desirable to keep a proof of result.. Screenshot come to help in this regards. In this blog post , I will explain , how to take a screenshot with Selenium Web Driver with C#. In future I will add another couple of post to explain , how to consolidate the screenshots into a PDF document. ...

September 6, 2016 · Aby George A

Element location using XPath Axis

During testing we will sometimes come up to situations where developers are not following best practises for testability . We will frequently come up situations where elements doesn’t have any unique identifiable property. XPath axis comes to help in those situations. We can identify elements using various XPath Properties List of various XPath Axis are available in https://developer.mozilla.org/en-US/docs/Web/XPath/Axes If you have well-defined properties to identify the element, use them as your locator. Please read locator strategy Using XPath and Other Parameters ...

September 3, 2016 · Aby George A

Element Location using XPath

XPath is XML query language which can be used for selecting nodes in XML. Hence it can be used to identify elements from DOM since they are represented as XHTML documents. Selenium WebDriver also supports XPath for locating elements. They also help to look for elements in both direction and hence it is generally slow compared to all other locator strategy. We can use XPath with both absolute path and relative path. ...

August 30, 2016 · Aby George A

Nunit Assert

Assert.AreEqual vs Assert.AreSame Very frequently I use Assert.AreEqual and Assert.AreSame for doing assertions in the code. Below is high level difference between both. Assert.AreSame Assert.AreSame checks whether both comparing objects are exactly the same ( reference indicate same object in memory) .It is normally known as Reference Equality Assert.AreEqual Assert.AreEqual checks whether both objects contain same value. It is normally known as Value Equality. For primitive value types ( like int, bool) this is straight forward. But for other types ( especially user defined objects) , it is depends on how the type defines equality. ...

August 22, 2016

Identifying elements using Locators in Selenium

Locators are html properties of a web element , which can be considered as an address of the element. An element will have various html properties. We can use Firebug extension or Chrome dev tools to identify different locators of an element. Selenium Web Driver provides two different methods for identifying html elements . _**FindElement **_for WebDriver and WebElement Class. When locating element matching specified criteria, it looks through DOM( Document Object Model) for matching element and return the first matching element. If there are no matching element, it will throw NoSuchElementFoundException ...

August 17, 2016 · Aby George A

Specflow - Sharing data between steps

In Specflow, Step definitions are global. So a scenario can have multiple step definitions which can be present in different classes. Sometimes, there arise a need to share the data between steps residing in different classes. How do we do it?? There are multiple ways to do it Context Injection Feature Context Scenario Context Let us look into more details about how to store and retrieve data using Scenario Context . ...

August 1, 2016 · Aby George A

Data Driven Framework - XML

I am not going to explain what is data driven framework or what is its benefits. All of them are pretty well-known . If not, just google it. Here I am going to explain a sample code which can be used to read from xml data files. This will be helpful to implement a data driven frame work for BDD testing , using Specflow or Cucumber Pre - requiste Code is written in Csharp . We need to add below reference to visual studio solution ...

July 29, 2016 · Aby George A

Data Driven Framework - Excel

In previous blog post, I have explained about how use XML for making a data driven framework for automation testing . It can be found here. I have also written about how to use jxl library for reading from excel and writing into Excel. Below is another code snippet to read all values of a row and save it into a hash map for accessing later during automation test. public HashMap GetAllDataForARow (String sheet, int Row){ HashMap DataMap = new HashMap(); try { Workbook wrk1 = Workbook.getWorkbook(new File(dataPath)); //Obtain the reference to the first sheet in the workbook Sheet sheet1 = wrk1.getSheet(sheet); int x =0; Cell colArow1 , colArow2; do { colArow1 = sheet1.getCell(x,0); colArow2 = sheet1.getCell(x,Row); DataMap.put(colArow1.getContents(), colArow2.getContents()); x=x+1; }while (colArow1.getContents() != ""); } catch (BiffException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }catch (IndexOutOfBoundsException e){ } return DataMap; }

July 30, 2016

Nodejs

This post is just for making notes during my learning of Node.js through various courses and online material. This will be always a work in progress blog post Node.js is an open source server side runtime environment, which is cross platform.It uses Javascript as its language check node version node --version Making web request in Node we can make webrequest by using inbuilt http or by using ‘request’ example : For making web request by http ...

July 12, 2016

Volunteering Experience

A couple of months back , I helped out to organize clinical examination for RACP. I created a tool ( Excel Macro) for finalizing exam schedules for all attendees. The roster should consider employee preference, examiner availability, timeslot, venue and other parameters. Below is what I got in return ( even though they misspelled my name).

October 16, 2015