In my setup for protractor
, I have configured multiple browsers through multiCapabilities
and am running tests on browserstack.
One of the key protractor specs/tests includes an afterEach()
block that checks if the browser console is empty:
afterEach(function() {
browser.manage().logs().get("browser").then(function (browserLog) {
expect(browserLog.length).toEqual(0);
});
});
An issue arises when running this spec on Internet Explorer, where it throws an UnknownError
:
UnknownError: Command not found: POST /session/6b838fe8-f4a6-4b31-b245-f4bf8f37537c/log
Upon further investigation, it was discovered that IE selenium webdriver
does not currently support session logs:
The question then arises: how can I handle this UnknownError
to allow the spec to pass despite encountering this specific error?
Alternatively, is there a way to make the afterEach()
block specific to certain capabilities/browsers or identify which capability/browser is currently being used?
Attempts were made using try/catch
and relying on the exception sender
, but console.log()
did not execute as expected:
afterEach(function() {
try {
browser.manage().logs().get("browser").then(function (browserLog) {
expect(browserLog.length).toEqual(0);
});
}
catch (e) {
console.log(e.sender);
}
});
To work around this issue, a duplicate spec was created without the failing afterEach()
block specifically for Internet Explorer.