-
Notifications
You must be signed in to change notification settings - Fork 1
How to Use the Shadow Root Functions
Biplav Ghosal edited this page Jan 7, 2021
·
3 revisions
e.g.👇 we have to click the A
Tag
1. To achieve this, we have to first find the shadow root from the shadow host. Choose any selectors of your choice from this list and store.
import {utils} from 'ya-done';
const webShadowHost = {locator: `//ns-cta[@href='/help-and-support/bills-and-payments/if-your-bills-wrong']`, locatorType: 'xpath'};
const webShadowRootElement = {locator: '.nds-cta.text.animated', locatorType: 'css'};
//To Click the Element
await utils.clickShadowRootElement.call(this, webShadowHost, webShadowRootElement);
//To get the innerText of the Element
const innerText = await utils.getInnerTextOfShadowRootElement.call(this, webShadowHost, webShadowRootElement);
If we want to interact with the web elements using Jquery and CSS selector, we can use the below functions after storing the selectors.
import {utils} from 'ya-done';
const webShadowHostCssSelector = {locator: 'ns-cta.bills.list-item', locatorType: 'css'};
const webShadowRootElementCssSelector = {locator: '.nds-cta.text.animated', locatorType: 'css'};
//To Click the Element
await utils.clickShadowRootElementByCssSelector.call(this, webShadowHostCssSelector, webShadowRootElementCssSelector);
//To get the innerText of the Element
const innerText = await utils.getInnerTextShadowRootElementByCssSelector.call(this, webShadowHostCssSelector, webShadowRootElementCssSelector);