My challenge involves a group of text fields all sharing the same class names. Here is the HTML code:
Each text field has identical class names, and I am attempting to automate inputting values into them by using the sendKeys method in Selenium. For this task, I am utilizing JavaScript (chai, mocha, node) to execute my automation.
<div>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
<textarea class="form-control textarea-multi" name="191_table_1">adad</textarea>
<textarea class="form-control textarea-multi" name="191_table_1">adadad</textarea>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
<textarea class="form-control textarea-multi" name="191_table_1"></textarea>
</div>
This was my approach: I attempted to use findElements by className and iterate through each one to fill out the text fields:
describe('complete text fields',function(){
it('fill all the text fields',function(done){
driver.findElements(By.css("input[type=\'form-control textarea-multi\']")).then(function(texts){
console.log("got the list of texts");
texts.forEach(function(textField){
console.log("sending keys for each of the text field");
textField.sendKeys("test");
count = Number(count) + 1;
console.log(count);
if(count === 6) {
done();
}
});
});
});
});
However, this process fails with a timeout error (Error: Timeout of 15000ms exceeded). Any assistance would be highly appreciated. Thank you in advance.