* Get elements by different locator types, including strict locator. * Should be used in custom helpers: * * ```js * this.helpers['WebDriver']._locate({name: 'password'}).then //... * ``` * * * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict lo
(locator, smartWait = false)
| 891 | * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator. |
| 892 | */ |
| 893 | async _locate(locator, smartWait = false) { |
| 894 | if (store.debugMode) smartWait = false |
| 895 | |
| 896 | // special locator type for Shadow DOM |
| 897 | if (this._isShadowLocator(locator)) { |
| 898 | if (!this.options.smartWait || !smartWait) { |
| 899 | const els = await this._locateShadow(locator) |
| 900 | return els |
| 901 | } |
| 902 | |
| 903 | const els = await this._locateShadow(locator) |
| 904 | return els |
| 905 | } |
| 906 | |
| 907 | // special locator type for ARIA roles |
| 908 | if (locator.role) { |
| 909 | return this._locateByRole(locator) |
| 910 | } |
| 911 | |
| 912 | // Handle role locators passed as Locator instances |
| 913 | const matchedLocator = new Locator(locator) |
| 914 | if (matchedLocator.isRole()) { |
| 915 | return this._locateByRole(matchedLocator.locator) |
| 916 | } |
| 917 | |
| 918 | if (!this.options.smartWait || !smartWait) { |
| 919 | if (this._isCustomLocator(locator)) { |
| 920 | const locatorObj = new Locator(locator) |
| 921 | return this.browser.custom$$(locatorObj.type, locatorObj.value) |
| 922 | } |
| 923 | |
| 924 | const els = await this.$$(withStrictLocator(locator)) |
| 925 | return els |
| 926 | } |
| 927 | |
| 928 | await this._smartWait(locator) |
| 929 | |
| 930 | if (this._isCustomLocator(locator)) { |
| 931 | const locatorObj = new Locator(locator) |
| 932 | return this.browser.custom$$(locatorObj.type, locatorObj.value) |
| 933 | } |
| 934 | |
| 935 | const els = await this.$$(withStrictLocator(locator)) |
| 936 | await this.defineTimeout({ implicit: 0 }) |
| 937 | return els |
| 938 | } |
| 939 | |
| 940 | _grabCustomLocator(locator) { |
| 941 | if (typeof locator === 'string') { |
no test coverage detected