Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listen for Browser Events in Protractor

Is there a way to attach event listeners to browser events in a Protractor test?

I know Protractor is running as a Node program, but I'm curious if anyone has done this with a Node package like browserevent.

Looking for any examples if so.

like image 679
sma Avatar asked Oct 31 '22 16:10

sma


1 Answers

In my opinion in the protractor spirit, No it's not possible . Protractor is a layer over selenium webdriver. Webdriver is a kind of JSON protocol that send command to communicate to the browser. Those command are store in a queue of promises and then come back async to Protractor. Then you could do Assertion with the "Expect" keyword of jasmine to inspect the DOM.

If you still need to find a way, you try the hacker way :

browser.driver.executeScript("YOUR JAVASCRIPT CODE HERE;");

Then you Wrap this call in a browser.wait(), but I would not recommend such way.

Thank you

like image 190
Hugo Doyon Avatar answered Nov 09 '22 12:11

Hugo Doyon