XPath generation library
Motification
To be used with selenium tests
Examples
var xpgen = ; // //*[@id='container']var path; path = xpgen; // //div[@id='container']//*[contains(@class, 'row')]path = xpgen; // //*[contains(text(), "hello")] path = xpath; // //a[href='http://classdojo.com']/img[0]path = xpath;
API
Chain .find(nodeName = "*")
Starts a chain with the given node name
Chain .path(name)
Returns a registered chain
// //*console; // //divconsole;
Chain .element(nodeName = "*)
Chain API
.index(value)
Sets the index for the element to search.
// div[5]xpgen; // div[5] xpgenindex5;
.contains(attribute, value)
// div[contains(text(), "tacos")]xpgen
.eq(attribute, value)
// div[@data-age='50']xpgen;
.neq(attribute, value)
not equal search:
// div[@data-age!='50']xpgen;
.gt(attribute, value)
// div[@data-age>'50']xpgen;
.lt(attribute, value)
// div[@data-age<'50']xpgen;
.gte(attribute, value)
// div[@data-age>='50']xpgen;
.lte(attribute, value)
// div[@data-age<='50']xpgen;
.or()
// div[@data-age='50' or @data-age='60']xpgen;
.and()
// a[contains(@class, 'account') and href='http://site.com/account']xpgen;
.register(name)
registers the chain so it can be re-used
// //div[contains(@class, 'container')]xpgen // //div[contains(@class, 'container')]//*[contains(@data-name, 'craig')]xpgen
AttrChain API
.contains(value)
xpgen