i have this piece of html, which is under a dropdown, and which appears after selecting somthing in the dropdown element:
<div class="mx-0 w-100 row">
<textarea id="notes" placeholder="Write here..." required="" class="form-control"> </textarea>
</div>
I want to use Selenium to click on it, write something and exit from the textarea. And actually I did it, but results vary depending on which selector I use, and I don't know why:
Here's my code actually working: I use wait for element visible and enabled because the above dropdown, when opened, covers the textarea. If I don't use them it gives a "not interactable" error.
const notes = await driver.wait(until.elementsLocated(By.css('textarea')), delay)
await driver.wait(until.elementIsVisible(notes[0]), delay)
await driver.wait(until.elementIsEnabled(notes[0]), delay)
await notes[0].sendKeys('Something to write')
// this TAB is for exiting from textarea, which let a button to appear
await notes[0].sendKeys(Key.TAB)
Now, if instead of the first line I use
const notes = await driver.wait(until.elementLocated(By.id('notes')), delay)
or
const notes = await driver.wait(until.elementLocated(By.xpath('//*[@id="notes"]')), delay)
and replacing obviously notes[0]
with notes
,it gives me
ElementNotInteractableError: element not interactable
The question is: Why does this happens? I do not like so much selecting an array element with numbers, but actually I am forced to and I don't get why the other selectors aren't working.