Skip to content

Instantly share code, notes, and snippets.

@hiepxanh
Created March 7, 2018 09:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hiepxanh/74eea6a54a93cc00ebd88115aa038361 to your computer and use it in GitHub Desktop.
selenium javascript hover button with async await
async login(driver:WebDriver) {
await driver.get('https://tiki.vn');
let loginElement = await driver.findElement(By.id('header-user'));
let strJavaScript = "var element = arguments[0];"
+ "var mouseEventObj = document.createEvent('MouseEvents');"
+ "mouseEventObj.initEvent( 'mouseover', true, true );"
+ "element.dispatchEvent(mouseEventObj);";
await driver.executeScript(strJavaScript, loginElement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment