Skip to content

Instantly share code, notes, and snippets.

View costea32's full-sized avatar

Constantin Pascal costea32

View GitHub Profile
@costea32
costea32 / gist:615fea91e921a1157985
Last active August 29, 2015 14:05
AssertionExtensions - PropertySetExample
public class BlogExampleObject
{
//Will always check that actual value is greater
// than attribute argument
//And will ignore comparison if expected is 0
[ValidateActualGreaterThan(0)]
public int Id { get; set; }
//Will always check that actual value is not null
//And will ignore comparison if expected is null
@costea32
costea32 / gist:f493aa13eb9f66ab7185
Last active August 29, 2015 14:05
AssertionExtension - PropertySetTestExample
[TestMethod]
public void BlogExample_PropertySet()
{
var expected = new BlogExampleObject
{
ChildObject = new TestObject{Value="ChildObjectValue1"},
ChildObjectList = new List<TestObject>{new TestObject{Value="ListObject1"}},
IgnoredProperty = "1",
ProcessedProperty = "Test"
};
@costea32
costea32 / gist:2fa1677832483c14c03b
Last active August 29, 2015 14:05
AssertionExtension - CummulativeAssert example
[TestMethod]
public void CumulativeAssert_MultipleFailuresExample()
{
//Some actions
CumulativeAssert.That(false,"Boolean failure");
//Some actions
CumulativeAssert.That(true, "Boolean passed");
//More actions
CumulativeAssert.That(1, Is.EqualTo(2), "int equality");
//Some actions
@costea32
costea32 / BasicWrappers.cs
Last active August 29, 2015 14:05
Selenium WebElement Basic Wrappers
public class HtmlControl
{
protected readonly IWebElement webElement;
public HtmlControl(IWebElement webElement)
{
this.webElement = webElement;
}
public void Click()
@costea32
costea32 / HtmlTable.cs
Last active August 29, 2015 14:05
Selenium TableElement
public class HtmlTable<T> : HtmlControl where T : HtmlRow, new()
{
private string rowFilterXpath = "descendant::tr";
public HtmlTable(IWebElement webElement): base(webElement)
{
}
public string RowFilterXpath
{
@costea32
costea32 / gist:bb5573b6fc5cc7e257d1
Created September 22, 2014 17:59
Object Map - Usual Examples
package org.openqa.selenium.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Example {
public static void main(String[] args) {
// Create a new instance of the html unit driver
@costea32
costea32 / ObjMap.cs
Last active August 29, 2015 14:06
Object Map - Simple Object Map Example
public class Page
{
protected readonly IWebDriver driver;
public Page(IWebDriver driver)
{
this.driver = driver;
}
public string Title
@costea32
costea32 / Page.cs
Created September 23, 2014 20:29
ObjectMap decent base Page
public abstract class Page
{
protected readonly IWebDriver driver;
protected Page(IWebDriver driver)
{
this.driver = driver;
MaxLoadingTime = TimeSpan.FromSeconds(30);
}
@costea32
costea32 / ElementNotPresent_With_DriverExtension.cs
Last active August 29, 2015 14:11
Checking Element is not present on web page
public static class WebDriverExtensions{
public static bool ElementExists(this IWebDriver webDriver, By @by)
{
return webDriver.FindElements(@by).Any();
}
public static IWebElement FindElementOrDefault(this IWebDriver webDriver, By @by)
{
return webDriver.FindElements(@by).FirstOrDefault();
}
@costea32
costea32 / ElementNotPresent_With_DriverExtension.cs
Created August 7, 2015 04:23
BlogExample_ElementNotPresent_With_DriverExtension
public static class WebDriverExtensions{
public static bool ElementExists(this IWebDriver webDriver, By @by)
{
return webDriver.FindElements(@by).Any();
}
public static IWebElement FindElementOrDefault(this IWebDriver webDriver, By @by)
{
return webDriver.FindElements(@by).FirstOrDefault();
}