0

I have a list of text fields each having the same class names. This is the html code:

each text field has the same class name and I am trying to automate the fields by sending keys to each text field by using the sendKeys method in selenium. I am using JavaScript(chai,mocha,node) to run 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 is what I tried. I tried to use findElements by className and iterate through of the className and then fill the each text field:

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();
                    }
                });
            });
        });
    });

but it fails with a time out error. (Error: Timeout of 15000ms exceeded.) Any help will be greatly appreciated Thank you in advance.

kushal
  • 31
  • 1
  • 6
  • Check here: http://stackoverflow.com/questions/16607039/in-mocha-testing-while-calling-asynchronous-function-how-to-avoid-the-timeout-er – Kushal Bhalaik May 14 '17 at 06:31

1 Answers1

1

Try to use:

By.css(".form-control.textarea-multi")
By.xpath("//*[@class='form-control textarea-multi"]
unickq
  • 1,497
  • 12
  • 18
  • I still get the same error. However, I tried to print the array size. And it appears to be zero. I tried both of your suggestions. driver.findElements(By.By.xpath("//*[@class='form-control textarea-multi']")) – kushal May 17 '17 at 22:23