Protractor - get result of sendChromiumCommand

308 views Asked by At

The goal: obtain a result of chromium command execution, e.g. Profiler report data

What I've done: I'm able to call chrome devtools command using browser.driver.sendChromiumCommand.

E.g. await browser.driver.sendChromiumCommand('Page.reload', {}) reloads page, so I can confirm that this is working.

The problem: the result of any command execution is always null

Here is my code

describe('Protractor Demo App', function() {
  it('whatever', async function() {
    await browser.get('http://juliemr.github.io/protractor-demo/');
    const data = await browser.driver.sendChromiumCommand('Page.reload', {
      scriptToEvaluateOnLoad: `(function(){return '123 })()`
    });
    console.log(data); // expected '123' but got 'null'
  });
});

Note: the issue isn't connected to a particular command, all of the devtools commands return null

1

There are 1 answers

0
r4d10 On BEST ANSWER

This is not a Protractor issue per se.

The problem is that underlying selenium-webdriver for Node.js uses send_command(which does not return result), but does not implement usage of send_command_and_get_result.

According to response from developers it's going to be fixed in next alpha release (current one is 4.0.0-alpha.7)

I suppose that, in order for this to work, Protractor's sendChromiumCommand is gotta get a sendChromiumCommandAndGetResult counterpart, once selenium-webdriver fix is available.