My company has a JavaScript-heavy (Backbone-based) web site living at an external domain which I have no control over. I'd like to automate some tasks. Basically I want to click on some things, fill out some form fields, and submit a button. However, I also want the ability to do logic tests and enter different values in fields based on various states of things in the page.
I know I can probably use Selenium for this, but are there any alternatives? Maybe a pure JavaScript solution?
For instance, if I could do this, it would be great:
$('#someButton').click();
if (parseInt($('#someDiv').text()) > x) {
    $('#someField').val(123);
    someCounter++;
}
$('#submitButton').click();
Even if I could inject custom JavaScript into the web page...that could work too.
You can do this with selenium using pure Js. basically you'll need the WebDriverJs.
Here some code example.
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();
driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
 return driver.getTitle().then(function(title) {
   return title === 'webdriver - Google Search';
 });
}, 1000);
driver.quit();
More information here https://code.google.com/p/selenium/wiki/WebDriverJs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With