Skip to content

Instantly share code, notes, and snippets.

View dcrosby42's full-sized avatar

David Crosby dcrosby42

  • Cisco Systems, Inc.
  • Grand Rapids MI
View GitHub Profile
var link = browser.FindViaJQuery(“.search_results.businesses .result a:contains(‘Applebees’)”).Click();
@dcrosby42
dcrosby42 / WatinSearchHelper_BrowserExtensions.cs
Created November 11, 2010 05:01
Extension method for WatiN.Core.Browser, utilizes in-page JS function WatinSearchHelper.getElementId()
using WatiN.Core;
namespace WatinSearchHelper
{
public static class BrowserExtensions
{
public static Element FindViaJQuery(this Browser browser, string cssSelector)
{
var elementId = browser.Eval(string.Format("WatinSearchHelper.getElementId(\"{0}\")", cssSelector));
return browser.Element(Find.ById(elementId));
}
@dcrosby42
dcrosby42 / watin_search_helper.js
Created November 11, 2010 04:59
Helper function to embed in your page to let WatiN execute a CSS-selector based search for a DOM element.
;WatinSearchHelper = function ($) {
var earTagId = 1;
var getElementId = function (cssSelector) {
var resultId = "_no_element_";
var el = $(cssSelector);
if (el.length > 0) {
var firstEl = el[0];
if (firstEl.id == "") {
// Give this element a contrived id so we can find it directly from the WatiN side:
@dcrosby42
dcrosby42 / gist:295900
Created February 5, 2010 16:03
New git repo from branch
# Creating a new git repository based on the subdirectory of an existing repository
# Got this from: http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository
git clone --no-hardlinks project327 compass
cd compass
git filter-branch --subdirectory-filter bloomfire-compass HEAD -- --all
git reset --hard
git gc --aggressive
git prune
class String
def from_json
ActiveSupport::JSON.decode(self)
end
end