简体   繁体   English

如何在打字稿中使用“ scrollIntoView()”

[英]How to use “scrollIntoView()” in Typescript

I am currently working on the automation of angular js application .. We are currently using typescript for the automation language. 我目前正在开发angular js应用程序的自动化。.我们目前正在使用typescript作为自动化语言。 I want to scroll to an element and then click on the particular element. 我想滚动到某个元素,然后单击特定元素。

 var element = element(by.className('learn-link'));
 browser.driver.executeScript("arguments[0].scrollIntoView(true);", element); element.click();

I want to know if this is the correct method for scrollIntoView() the element . 我想知道这是否是scrollIntoView()元素的正确方法。

const element: ElementFinder = element(by.className('learn-link'));
await browser.executeScript("arguments[0].scrollIntoView(true)", element);
await element.click();

remember that for using await for resolving promises your function should be async . 记住,使用await来解决诺言,您的函数应该是async

async someFunction() {
await ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM