I'm using Selenium WebDriver using Java. I'm having a textarea and I would like to clear default content and enter new content in it. Functionality is such that if I clear text from textarea and hit Tab button, then default text will auto fill. Below is HTML of textarea:
<textarea autocomplete="off" class="form-control rd-control rd-control--textarea empty" cols="20" data-bind="value: offerTitle, expandedTextArea: offerTitle, valueUpdate: 'afterkeydown', customerRequiredFieldsBinding" id="CheckoutWelcomeTitle" name="CheckoutWelcomeTitle" placeholder="ex. Here comes the best offer" rows="1" type="text" data-autosize-on="true" style="overflow-y: hidden; height: 35.9792px;" onblur="setTextColorDefault(this)" oninput="setTextColor(this)">Let's bid on a discount code!</textarea>
I tried using:
driver.findElement(By.id("CheckoutWelcomeTitle")).clear()
But this didn't work.
I also tried this:
driver.findElement(By.id("CheckoutWelcomeTitle")).sendKeys(Keys.CONTROL + "a")
driver.findElement(By.id("CheckoutWelcomeTitle")).sendKeys(Keys.DELETE)
This sometimes works but not always. Sometimes it clears data and refills default text.
Is there any other way I can clear this textarea in a way that it would work every time?
In case if it helps, developers have used JavaScript to refill the text box on blur event.
Edit: I have used explicit wait with the condition of the element to be clickable.