Skip to content

Instantly share code, notes, and snippets.

@stuartf7
stuartf7 / SQL.sql
Created February 2, 2012 23:16
Example of how to set the first day of the week in SQL
-- Set the first day of the week to monday
SET DATEFIRST 1
-- Set the first day of the week to tuesday
SET DATEFIRST 2
-- Set the first day of the week to sunday
SET DATEFIRST 7
@stuartf7
stuartf7 / qunit.teamcity.js
Created February 6, 2012 22:54
qUnit output for Teamcity
QUnit.moduleStart = function (name, testEnvironment) {
console.log("##teamcity[testSuiteStarted name='" + name + "']");
};
QUnit.moduleDone = function (name, failures, total) {
console.log("##teamcity[testSuiteFinished name='" + name + "']");
};
QUnit.testStart = function (name, testEnvironment) {
console.log("##teamcity[testStarted name='" + name + "']");
@stuartf7
stuartf7 / run-qunit.js
Created February 7, 2012 18:43
Execute QUnit Test in PhantomJS
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param onReady what to do when testFx condition is fulfilled,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
@stuartf7
stuartf7 / GoogleTests.cs
Created June 27, 2012 14:22
Example Fixture Setup For Selenium Testing
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace selenium_examples
{
[TestFixture]
public class GoogleTests
{
@stuartf7
stuartf7 / gist:3004375
Created June 27, 2012 14:25
Simple Selenium Test
[Test]
public void GooglePageTitle()
{
Assert.AreEqual("Google", _driver.Title);
}
@stuartf7
stuartf7 / test.cs
Created July 4, 2012 16:13
Some More Selenium Tests
[Test]
public void SearchForTest()
{
IWebElement searchbox = _driver.FindElement(By.Name("q"));
searchbox.SendKeys("Test");
searchbox.SendKeys(Keys.Enter); //send [enter] key to the control.
Assert.AreEqual("Test - Google Search", _driver.Title);
}
@stuartf7
stuartf7 / Select.cs
Created July 4, 2012 16:23
Selenium Select Logic
using System.Collections.Generic;
namespace OpenQA.Selenium.Support.UI
{
public class Select
{
private readonly IWebElement element;
public bool Multiple { get; private set; }
@stuartf7
stuartf7 / UnexpectedTagNameException.cs
Created July 4, 2012 16:25
Selenium Select UnexpectedTagNameException
using System;
using System.Runtime.Serialization;
namespace OpenQA.Selenium.Support.UI
{
[Serializable]
public class UnexpectedTagNameException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="UnexpectedTagNameException"/> class with
@stuartf7
stuartf7 / example.cs
Created July 4, 2012 16:27
Selenium Select Example Use
Select select = new Select(webElement);
select.SelectByText("Select Me");
@stuartf7
stuartf7 / SelectTests.cs
Created July 4, 2012 16:28
Selenium Select Unit Tests
using System.Collections.Generic;
using System.Collections.ObjectModel;
using NMock2;
using NUnit.Framework;
namespace OpenQA.Selenium.Support.UI
{
[TestFixture]
public class SelectTests
{