* Clicks on an element if it's present. If the element is not found, * catch the exception, log the failure to the console, but do not cause the test to fail. * For scenario where an element such as a scroll button does not * show up because of render differences, proceed to the next step
(rawLocator, timeout = 2000)
| 858 | * @param timeout - The maximum time in ms to wait for the element |
| 859 | */ |
| 860 | async clickElementSafe(rawLocator, timeout = 2000) { |
| 861 | try { |
| 862 | const locator = this.buildLocator(rawLocator); |
| 863 | const elements = await this.driver.wait( |
| 864 | until.elementsLocated(locator), |
| 865 | timeout, |
| 866 | ); |
| 867 | |
| 868 | await Promise.all([ |
| 869 | this.driver.wait(until.elementIsVisible(elements[0]), timeout), |
| 870 | this.driver.wait(until.elementIsEnabled(elements[0]), timeout), |
| 871 | ]); |
| 872 | await elements[0].click(); |
| 873 | } catch (e) { |
| 874 | console.log(`Element ${rawLocator} not found (${e})`); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | /** |
| 879 | * Clicks a nested button element by its text content. |
no test coverage detected