本文整理汇总了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]);');
};