Created
November 11, 2010 04:59
-
-
Save dcrosby42/672032 to your computer and use it in GitHub Desktop.
Helper function to embed in your page to let WatiN execute a CSS-selector based search for a DOM element.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;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: | |
firstEl.id = "_watin_search_" + earTagId++; | |
} | |
resultId = firstEl.id; | |
} | |
return resultId; | |
}; | |
return { getElementId: getElementId }; | |
} (jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment