Can I access documents or window objects from a protractor test?

Perhaps this is not possible, I really don't understand how node works. I would like to be able to run the approval of a document object after the page has been retrieved into the protractor. Is this possible, and if so, how?

thanks!

+6
source share
2 answers

Ok, I found the answer, so I answer my own question for others:

You can execute javascript using browser.executeScript and then use the return value in your promise, for example:

browser.executeScript('return document._config').then( function(_config){ expect( _config.epid ).toBe( 1 ); }); 
+10
source

The function you are looking for is called executeScript or executeAsyncScript. They will help you to execute arbitrary javascript fragment in the browser.

Take a look at these links: http://angular.imtqy.com/protractor/#/api?view=webdriver.WebDriver.prototype.executeScript http://angular.imtqy.com/protractor/#/api?view=webdriver. WebDriver.prototype.executeAsyncScript

+3
source

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


All Articles