Giter Site home page Giter Site logo

rohanbaraskar / pageobjectframeworkcsharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jrmsweitzer/pageobjectframeworkcsharp

0.0 2.0 0.0 54.94 MB

A Framework for Selenium and PageObjects, with built-in logging support and screenshots.

C# 100.00%

pageobjectframeworkcsharp's Introduction

PageObjectFramework

A Framework for Selenium and PageObjects, with built-in logging support and screenshots.

To use this Framework, you'll have to have Visual Studio installed. I used VS2013 Community Edition, which is free to download here: http://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx

Once you get that installed, you can use VS2013's built-in git support to pull this project.

  1. Go to the Team Explorer window. View -> Team Explorer
  2. Click the outlet plug at the top (Connect to Team Projects)
  3. Click 'Clone'
  4. Use URL: https://github.com/jrmsweitzer/PageObjectFramework

If you have VS2012 instead, you can go to the URL listed above, and click "Clone in desktop". From there, you can open it with your IDE.

To build a Page Object, just start with the TemplateModel found in the Models folder, and edit it to your specific page. It's really simple once you get started.

You can find an XPath Cheat Sheet in the Resources folder, which can help you create custom XPaths for your elements. Always use XPath as a last resort, as an XPath address can change with a DOM update.

I've also created and included a ByFormatter. That is, in effect, a By combined with a string formatter. You can find an example of one of those in use in the YouTube model, in the method ClickVideoAtIndex(int n);

The Logger that's included will log actions (all the selenium button clicks and such), as well as test runs and their results (pass/fail). The default location is C:/Selenium/Logs, but can be changed in App.config, with the logDirectory value. You can also turn off the action logging with the logAllActions value. The test suite also takes screenshots of the browser when the test finishes, so you can see where it passed/failed. The default location of that is C:\Selenium\Results\Screenshots, but again, can be edited in App.Config.

The WindowHandler is also a custom creation of mine. Its purpose is to help you keep track of open windows, and to send control of your selenium driver back and forth between the open windows. You can see an example of this in action in the Email Model, in the method ComposeNewEmail(string to, string subject, string message).

Every Selenium Test should implement PageObjectTestBase, to gain access to the logger and screenshots, without any extra coding on your part. Similarly, every PageObject Model you create should implement PageObjectModelBase. By doing that, you'll gain access to all of the common methods such as Click(by) and SendKeys(by, value).

The last thing to touch up on is which browser the tests run in. By default, the tests will run in Chrome. However, that can be changed in the App.config file.

*** USE NUNIT WHEN WRITING YOUR TESTS! THERE IS A BUG WHERE THE TESTS WON'T CLOSE IF USING VISUAL STUDIO'S TESTING FRAMEWORK! ***

I hope you enjoy using this Framework! If you have any questions/comments/concerns, feel free to email me at [email protected]!

Thanks, ~Jeremy Sweitzer Developer II - Catalyst IT Services.



<shameless plug>
	<follow_me>
		<Yammer>
			https://www.yammer.com/catalystitservices.com/users/jsweitzer
		</Yammer>
		<LinkedIn>
			https://www.linkedin.com/pub/jeremy-sweitzer/69/6a5/3b9
		</LinkedIn>
	</follow_me>
</shameless plug>

pageobjectframeworkcsharp's People

Contributors

jrmsweitzer avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.