-
Notifications
You must be signed in to change notification settings - Fork 72
Automate Testing : Browserstack and SeleniumJS
A simple test can be run using
node tests.js -t http://map.geo.admin.ch
in the folder test/selenium/
Be sure to load the BROWSERSTACK_USER and BROWSERSTACK_PASSWORD environment variables locally.
- Enable implicit timeout to give the driver some time before **timing out **
driver.manage().timeouts().implicitlyWait(TIMEOUT);
- Maximize the browser resolution (only on desktop browsers)
driver.manage().window().maximize();
- Resize the browser resolution (only on desktop browsers)
driver.manage().window().resize(x,y);
- Load a page / Refresh
driver.get(target + '/?lang=de');
- Click on an element found in the page using xpath
driver.findElement(webdriver.By.xpath("//*[@id='pulldown']")).click();
- Push keys in a field found in the page using xpath
driver.findElement(webdriver.By.xpath("//*[@type='search']")).sendKeys('Bern');
- Compare two URLS (require assert module)
driver.getCurrentUrl().then(function(url) {
assert.ok(url.indexOf(QUERYSTRING_OF_BERN) > -1);
});
See : https://code.google.com/p/selenium/wiki/WebDriverJs for more functions or http://selenium-suresh.blogspot.ch/2012/09/selenium-web-driver-command-list.html
See : https://www.browserstack.com/automate/capabilities and http://www.browserstack.com/automate/node
-
Webdrivers are generated (Capabilities)
-
Tests are loaded (start / search and print)
-
Browserstack sessions are created (one for each webdriver)
-
Tests are performed
-
Errors are reported
Since the webdriver is not getting any infos from the User Interface (UI), we need to add some safety parameters to ensure that the webpage we assume to test is really the webpage we are testing
- Manage time use (use implicit timeout and not sleep)
- Check the DOM/JS state after passing a driver command (search for new/modified DOM element after click event/ key input)