I am trying to test a simple form using Selenium, WebDriver.io and Node.js (with Mocha). So I have something like this:
var webdriverio = require('webdriverio'); var expect = require('expect'); describe('Test form', function(){ beforeEach(function() { browser.url('/'); }); it('should save object', function() { expect(browser.executeScript('return window.data;')).to.be([]); }); afterEach(function() { if (this.currentTest.state !== "passed") { browser.saveScreenshot(); } }); });
My wdio.conf.js
:
var selenium = require('selenium-standalone'); var seleniumServer; exports.config = { host: '127.0.0.1', port: 4444, specs: [ 'test/*.spec.js' ], capabilities: [{ browserName: 'chrome' }], baseUrl: 'http://localhost:8080', framework: 'mocha', mochaOpts: { ui: 'bdd' }, onPrepare: function() { return new Promise((resolve, reject) => { selenium.start((err, process) => { if(err) { return reject(err); } seleniumServer = process; resolve(process); }) }); }, onComplete: function() { seleniumServer.kill(); } };
But on the console, I have: browser.executeScript is not a function
. What is the correct way to execute a script in a browser context using these tools?
source share