Step-by-step guide to start first Test Project

Before you start: Read about Page object pattern. The Page Object Pattern wraps all elements, actions and validations happening on a page in one single object- Page Object

Official:

Unofficial:

Selenium Documentation

Download and Install

  1. Download and install Visual Studio 2015 https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx (free version)
  2. Launch VS and create a new project: Unit test project
  3. Install Nuget package manager and navigate to it.
  4. From the Manage Nuget Packages -> search online for ‘Selenium’ ; Install Selenium WebDriver

First Lines of code

  1. Create an instance of a driver (*Only the FirefoxDriver can be created without parameters. For all other drivers you need to point the location where the specific driver is downloaded
    IWebDriver driv1 = new CromeDriver(); (“C:\\pathtomyCromedriverbinaries”);
  2. Write methods to locate elements on web-page( by id/xpath/css/linktext/tagname/name/class)
    IWebElement element = driv1.FindElement(By.Id(UniqueId));
  3. Use a Chain of Locators in order to find a specific element.
    IWebElement ToFind = this.driv1.FindElement(By.ClassName(“firstElementTable)).FindElement(By.Id(“secondElement));
  4. Iwebelemet methods and properties:
    iwebelement

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s