webdriverjs
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -9,37 +9,43 @@ module.exports = function element (value, callback) { | ||
// check value type | ||
// use id strategy if value starts with # and doesnt contain any other CSS selector-relevant character | ||
if(value.indexOf('#') === 0 && value.search(/(\s|>|\.|[|])/) === -1) { | ||
using = 'id'; | ||
value = value.slice(1); | ||
if (arguments.length === 3) { | ||
using = arguments[0]; | ||
value = arguments[1]; | ||
callback = arguments[2]; | ||
} else { | ||
// check value type | ||
// use id strategy if value starts with # and doesnt contain any other CSS selector-relevant character | ||
if(value.indexOf('#') === 0 && value.search(/(\s|>|\.|[|])/) === -1) { | ||
using = 'id'; | ||
value = value.slice(1); | ||
// use xPath startegy if value startes with // | ||
} else if(value.indexOf('//') === 0) { | ||
using = 'xpath'; | ||
// use xPath startegy if value startes with // | ||
} else if(value.indexOf('//') === 0) { | ||
using = 'xpath'; | ||
// use link text startegy if value startes with = | ||
} else if(value.indexOf('=') === 0) { | ||
using = 'link text'; | ||
value = value.slice(1); | ||
// use link text startegy if value startes with = | ||
} else if(value.indexOf('=') === 0) { | ||
using = 'link text'; | ||
value = value.slice(1); | ||
// use partial link text startegy if value startes with =* | ||
} else if(value.indexOf('*=') === 0) { | ||
using = 'partial link text'; | ||
value = value.slice(2); | ||
// use partial link text startegy if value startes with =* | ||
} else if(value.indexOf('*=') === 0) { | ||
using = 'partial link text'; | ||
value = value.slice(2); | ||
// use tag name strategy if value contains a tag | ||
// e.g. "<div>" or "<div />" | ||
} else if(value.search(/<[a-zA-Z-]+( \/)*>/g) >= 0) { | ||
using = 'tag name'; | ||
value = value.replace(/<|>|\/|\s/g,''); | ||
// use tag name strategy if value contains a tag | ||
// e.g. "<div>" or "<div />" | ||
} else if(value.search(/<[a-zA-Z-]+( \/)*>/g) >= 0) { | ||
using = 'tag name'; | ||
value = value.replace(/<|>|\/|\s/g,''); | ||
// use name strategy if value queries elements with name attributes | ||
// e.g. "[name='myName']" or '[name="myName"]' | ||
} else if(value.search(/\[name=("|')([a-zA-z0-9-_]+)("|')\]/) >= 0) { | ||
using = 'name'; | ||
value = value.match(/\[name=("|')([a-zA-z0-9-_]+)("|')\]/)[2]; | ||
// use name strategy if value queries elements with name attributes | ||
// e.g. "[name='myName']" or '[name="myName"]' | ||
} else if(value.search(/\[name=("|')([a-zA-z0-9-_]+)("|')\]/) >= 0) { | ||
using = 'name'; | ||
value = value.match(/\[name=("|')([a-zA-z0-9-_]+)("|')\]/)[2]; | ||
// if nothing fits with the supported strategies we fall back to the css selector strategy | ||
} else { | ||
using = 'css selector'; | ||
// if nothing fits with the supported strategies we fall back to the css selector strategy | ||
} else { | ||
using = 'css selector'; | ||
} | ||
} | ||
@@ -46,0 +52,0 @@ |
{ | ||
"name": "webdriverjs", | ||
"description": "A nodejs bindings implementation for selenium 2.0/webdriver", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"homepage": "https://github.com/camme/webdriverjs", | ||
@@ -6,0 +6,0 @@ "author": "camilo tapia <camilo.tapia@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235022
142
3521