I use WebStorm to write my javascript tests. I have include Selenium WebDriver (+ chromedriver) to run my tests in browser. As a test-runner framework I use Mocha.
The problem is: when I try to debug my test and set a breakpoint into code, while debugging WebDriver does not starts. And as a result I could not see any variables realtime.
Code example:
// Add external libraries
var test = require('selenium-webdriver/testing'), webdriver = require('selenium-webdriver'), By = require('selenium-webdriver').By;
var mocha = require('./node_modules/mocha/mocha.js'), chai = require('chai'), chaiuse = require('chai-as-promised'), expect = require('chai').expect;
var assert = require('assert');
// global variable for webdriver browser
var browser;
// Main part with test suites
test.describe('Suite 1', function() {
this.timeout(5000);
test.beforeEach( function(){ // Executes before each test
browser = new webdriver.Builder().usingServer().withCapabilities({ 'browserName' : 'chrome', 'timeout' : '5000' }).build();
});
test.afterEach( function(){ // Executes after each test
browser.close();
});
test.it('Get Fields', function(done) {
browser.get('http://google.com');
var btnFirst = browser.wait(webdriver.until.elementLocated(webdriver.By.name('btnK'), 30000));
var btnSecond = browser.findElement(webdriver.By.name('btnI')).getAttribute("name");
btnSecond.then(function(text) {
console.log("Name of Second button: " + text + "\n");
assert.equal(text,'btnI','Button with name \'btnI\' not presented');
});
done();
});
});
And so for now all process is like black-box tests development.
I have tried DevTools - a chrome console to work. But it just run all test without pause on breakpoints.Command:
devtool node_modules/mocha/bin/_mocha -qc -- ./Tests.js --break
On C# + Selenium WebDriver I have no problems with step by step debugging, but now I need to do that on JavaScript + Selenium WebDriver.
Please, give an advice?