In the context of a Protractor script testing an AngularJS app, I have included the following code within a describe
block.
beforeEach(function() {
browser.get('index.html#/device_list');
browser.executeScript("chrome.bluetooth = {};");
browser.executeScript("console.log('test')");
browser.executeScript("alert('test')");
});
Running the tests without this code results in expected failures. However, upon adding it and executing the script, while the object isn't created and the console log doesn't appear, an alert is displayed (along with an asynchronous error).
I have attempted to remove the alert command, but there still isn't any object or log present.
Why is this happening? Is it feasible to create a basic object for test usage using executeScript in Protractor? If not, are there alternative approaches that don't require building a service?
To monitor the console log, I've integrated the following code snippet into the Protractor script:
browser.manage().logs().get('browser').then(function(browserLog) {
if(browserLog.length > 0) {
console.log(browserLog);
}
});