Monday, November 2, 2020

Deal with Shadow DOM in Selenium

 



From

https://medium.com/rate-engineering/a-guide-to-working-with-shadow-dom-using-selenium-b124992559f

async function getExtShadowRoot() {  let shadowHost;  await (shadowHost = driver.findElement(By.css(CSS_SHADOW_HOST)));  return driver.executeScript("return arguments[0].shadowRoot",                                                                 shadowHost);}
async function findShadowDomElement(shadowDomElement) {  let shadowRoot;  let element;  await (shadowRoot = getExtShadowRoot());  await shadowRoot.then(async (result) => {    await (element = result.findElement(By.css(shadowDomElement)));  });

return element;
}

No comments:

Post a Comment

API interview questions

  https://www.katalon.com/resources-center/blog/web-api-testing-interview-questions/ Top 50+ Web API Testing Interview Questions [Ultimate l...