| 155 | } |
| 156 | |
| 157 | async clear(): Promise<void> { |
| 158 | const input = await this.findTextarea(); |
| 159 | if (input) { |
| 160 | const isContentEditable = await input.getAttribute('contenteditable'); |
| 161 | |
| 162 | if (isContentEditable === 'true') { |
| 163 | await input.click(); |
| 164 | await browser.pause(50); |
| 165 | await browser.execute((element: HTMLElement) => { |
| 166 | element.focus(); |
| 167 | element.textContent = ''; |
| 168 | const inputEvent = typeof InputEvent !== 'undefined' |
| 169 | ? new InputEvent('input', { bubbles: true, inputType: 'deleteContentBackward', data: null }) |
| 170 | : new Event('input', { bubbles: true }); |
| 171 | element.dispatchEvent(inputEvent); |
| 172 | element.dispatchEvent(new Event('change', { bubbles: true })); |
| 173 | }, input); |
| 174 | |
| 175 | await browser.waitUntil(async () => (await this.getValue()) === '', { |
| 176 | timeout: 2000, |
| 177 | interval: 100, |
| 178 | timeoutMsg: 'Chat input was not cleared', |
| 179 | }); |
| 180 | } else { |
| 181 | // Regular textarea |
| 182 | await input.clearValue(); |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | async clickSend(): Promise<void> { |
| 188 | const selectors = [ |