Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor: print found element properties in console while debuging

I'm debugging protractor tests in Webstorm. When I add this code:

 var title = element(by.xpath('//div[@class="title"]'));
 title.getText().then(function (text)
       {
           console.log(text);
       });
 expect(title.getText()).toEqual('Opportunities');

I get printed in console desired text.

How to execute this directly in console?
When I add breakpoint on expect line 6 the part console.log(text); is not printed and I receive this output in console when I try to get elem text:

> ‌‌title.getText()
< ‌ElementFinder
> ‌‌title.getText().then(function (text)
{
console.log(text);
});
< ManagedPromise

Is is possible to find elements and print it properties in debug console?

like image 259
pbaranski Avatar asked Aug 09 '16 13:08

pbaranski


1 Answers

Selenium commands are executed asynchronously, which implies that all the calls are queued and are not yet executed if you stop the execution on the expect line.

Moreover it's probably not possible to get the properties from the console. For instance calling .getText() in the console will queue the call but it won't be executed since the control flow is not running.

like image 74
Florent B. Avatar answered Sep 17 '22 23:09

Florent B.