Empty response in Protractor console.log

2019-08-28 18:28发布

问题:

I have done very basic script in protractor cucumber framework and use Chai and Chai as Promised as assert libraries.

browser.get('http://www.angularjs.org');

 var elm = element(by.id('the-basics'));
        elm.getText().then(function(txt) {
            console.log("txt: " + txt);
        });

But, I cannot see anything is written in terminal.

I tried with xpath as well and get the same empty response.

var elm = element(by.id('//h3[@id='the-basics']'));
            elm.getText().then(function(txt) {
                console.log("txt: " + txt);
            });

Have I done anything wrong here?