Here is a clean node.js wrapper around the java API for selenium web server:
https://npmjs.org/package/webdriver-sync
Here is an example:
var webdriverModule = require("webdriver-sync"); var driver = new webdriverModule.ChromeDriver; var By = webdriverModule.By; var element = driver.findElement(By.name("q")); element.sendKeys("Cheese!"); element.submit(); element = driver.findElement(By.name("q")); assert.equal(element.getAttribute('value'), "Cheese!");
Save this in a .js file and run it with node.
The module is a clean shell, so things like sleep or synchronous calls are possible. Here is the current module interface:
module.exports={ ChromeDriver:ChromeDriver, FirefoxDriver:FirefoxDriver, HtmlUnitDriver:HtmlUnitDriver, By:new By(), ExpectedConditions:new ExpectedConditions(), WebDriverWait:WebDriverWait, Credentials:UserAndPassword, Cookie:Cookie, TimeUnits:TimeUnits, sleep:function(amount){ java.callStaticMethodSync( "java.lang.Thread", "sleep", new Long(amount) ); } };
You can see the integration test, which tests the full capabilities here:
https://github.com/jsdevel/webdriver-sync/blob/master/test/integrations/SmokeIT.js
source share