import { browser , by , element , ElementFinder } from 'protractor' ; import { promise } from 'selenium-webdriver' ; import { AppPage } from './app.po' ; export class NamespaceScrollPage extends AppPage { getPath ( ) { return '/namespace' ; } getContainer1ScrollTop ( ) { return this . getScrollTop ( by . css ( '#container1' ) ) ; } getContainer2ScrollTop ( ) { return this . getScrollTop ( by . css ( '#container2' ) ) ; } getContainer3ScrollTop ( ) { return this . getScrollTop ( by . css ( '#container3' ) ) ; } getTarget2OffsetTop ( ) { return this . getOffsetTop ( by . css ( '#scrollTarget2' ) ) ; } getTarget3OffsetTop ( ) { return this . getOffsetTop ( by . css ( '#scrollTarget3' ) ) ; } triggerDefaultNamespaces ( ) { return this . triggerAButton ( by . css ( '#startDefaultNamespaceScrollsButton' ) ) ; } triggerDefaultAndCustomNamespaceScroll ( ) { return this . clickButtonsSimultaneously ( element ( by . css ( '#startDefaultNamespaceScrollsButton' ) ) , element ( by . css ( '#startCustomNamespaceScrollsButton' ) ) ) ; } scheduleStopAllButtonClick ( ) { return browser . driver . executeScript ( 'var button = arguments[0]; setTimeout(function(){button.click()}, 1500)' , element ( by . css ( '#stopAllNamespaceScrollsButton' ) ) . getWebElement ( ) ) ; } scheduleDefaultButtonClick ( ) { return browser . driver . executeScript ( 'var button = arguments[0]; setTimeout(function(){button.click()}, 1500)' , element ( by . css ( '#stopDefaultNamespaceScrollsButton' ) ) . getWebElement ( ) ) ; } /**
     * Click two buttons shortly after another. Protractor would wait for the click action
     * to finish before pressing the next one, thus we use executeScript directly
     */ clickButtonsSimultaneously ( ... buttons ) { return browser . driver . executeScript ( 'arguments[0].forEach(function(arg){arg.click()});' , buttons . map ( button => button . getWebElement ( ) ) ) ; } }