本文整理匯總了TypeScript中protractor.browser.executeAsyncScript方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript browser.executeAsyncScript方法的具體用法?TypeScript browser.executeAsyncScript怎麽用?TypeScript browser.executeAsyncScript使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類protractor.browser
的用法示例。
在下文中一共展示了browser.executeAsyncScript方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should jump scroll position down and slowly scroll back up', async () => {
// The estimate of the total content size is exactly correct, so we wind up scrolled to the
// same place as if we slowly scrolled down.
await browser.executeAsyncScript(scrollViewportTo, viewport, 2000);
const offScreen = element(by.css('.demo-virtual-scroll-uniform-size [data-index="39"]'));
const onScreen = element(by.css('.demo-virtual-scroll-uniform-size [data-index="40"]'));
expect(await isVisibleInViewport(offScreen, viewport)).toBe(false);
expect(await isVisibleInViewport(onScreen, viewport)).toBe(true);
// As we slowly scroll back up we should wind up back at the start of the content.
await browser.executeAsyncScript(smoothScrollViewportTo, viewport, 0);
const first = element(by.css('.demo-virtual-scroll-uniform-size [data-index="0"]'));
expect(await isVisibleInViewport(first, viewport)).toBe(true);
});
示例2: it
it('should measure performance', function() {
browser.sleep(3000); // wait for extension to load
browser.driver.get(TEST_URL);
browser.executeScript('window.startProfiler()').then(function() {
console.log('started measuring perf');
});
browser.executeAsyncScript('setTimeout(arguments[0], 1000);');
browser.executeScript('window.forceGC()');
browser.executeAsyncScript('var cb = arguments[0]; window.getProfile(cb);')
.then(function(profile: any) {
assertEventsContainsName(profile, 'gc');
assertEventsContainsName(profile, 'script');
});
});
示例3:
const goTo = async url => {
// Go to the specified URL and then unregister the ServiceWorker
// to ensure subsequent requests are passed through to the server.
await browser.get(url);
await browser.executeAsyncScript(cb => navigator.serviceWorker
.getRegistrations()
.then(regs => Promise.all(regs.map(reg => reg.unregister())))
.then(cb));
};
示例4:
const whenAllStable = (): promise.Promise<any> => {
return browser.executeAsyncScript('window.frameworkStabilizers[0](arguments[0]);');
};