| 243 | } |
| 244 | |
| 245 | export async function clickElementByXPath(driver: WebDriver, xpath: string, isInButtonArea: boolean) { |
| 246 | return await retry(5, driver, async function (driver, count) { |
| 247 | if (count > 1 && config.LOG_DETAILS) console.log("clickElementByXPath", xpath, "attempt #", count); |
| 248 | let elem = await findByXPath(driver, xpath, isInButtonArea); |
| 249 | if (!elem) throw new Error(`Element with xpath ${xpath} not found`); |
| 250 | await elem.click(); |
| 251 | }); |
| 252 | // Stale element possible: |
| 253 | // return to(driver.findElement(By.xpath(xpath)).click()); |
| 254 | } |
| 255 | |
| 256 | export async function getTextByXPath(driver: WebDriver, xpath: string, isInButtonArea: boolean): Promise<string> { |
| 257 | return await retry(5, driver, async function (driver, count) { |