How to set 3 date in my protractor test?

Question!

I have 3 dates field in a row, and I'm trying to include randomly date on it, but, protractor is too fast and set something like:

  • first data: 01/08/1990 (correct)
  • second data: 01/09/0009 (invalid)
  • last data : 01/10/0007(invalid)

So, I used browser.sleep(200) and it's works, but, there is another way to do? Is this the correct way?

var dataPublicacao = element(by.xpath("//label[. = 'Data de Publicação*']/following-sibling::input"));
        dataPublicacao.sendKeys(RetornaDataAleatoria());
        browser.sleep(200);
        var dataInicio = element(by.xpath("//label[. = 'Inicio Vigência*']/following-sibling::input"));
        dataInicio.sendKeys(RetornaDataAleatoria());
        browser.sleep(200);
        var fimVigencia = element(by.xpath("//label[. = 'Fim Vigência']/following-sibling::input"));
        fimVigencia.sendKeys(RetornaDataAleatoria());


This video can help you solving your question :)
By: admin