Handling Unknown Protractor Errors

I have a protractor setup with several browsers configured through multiCapabilities , running tests in a browser.

One of my specs / tests of the prototype key contains the following afterEach() block:

 afterEach(function() { browser.manage().logs().get("browser").then(function (browserLog) { expect(browserLog.length).toEqual(0); }); }); 

which checks that the browser console is empty (there are no errors on the console).

Problem : when I run this specification in Internet Explorer, I get an UnknownError :

UnknownError: command not found: POST / session / 6b838fe8-f4a6-4b31-b245-f4bf8f37537c / log

After a quick research, I found that IE selenium webdriver does not yet support session logs:

Question: how can I catch this UnknownError and pass the specification pass in case of this particular error?

Or, to enable it, is it possible to be able to block the afterEach() / browser-specific block, or to know which one is currently working?


I tried using try/catch and try to rely on the sender exception, but console.log() fails:

 afterEach(function() { try { browser.manage().logs().get("browser").then(function (browserLog) { expect(browserLog.length).toEqual(0); }); } catch (e) { console.log(e.sender); } }); 

As a workaround, I duplicate the same specification, but without this afterEach() block, especially for Internet Explorer.

+5
source share
1 answer

One option was found - using getCapabilities() to get the current browser name:

 afterEach(function() { browser.driver.getCapabilities().then(function(caps) { var browserName = caps.caps_.browserName; if (browserName !== "internet explorer") { browser.manage().logs().get("browser").then(function (browserLog) { expect(browserLog.length).toEqual(0); }); } }); }); 

In this case, browser logs will not be checked when working with Internet Explorer.

+5
source

Source: https://habr.com/ru/post/1209638/


All Articles