javascript - How to set 3 date in my protractor test? -
i have 3 dates field in row, , i'm trying include randomly date on it, but, protractor fast , set like:
- first data: 01/08/1990 (correct)
- second data: 01/09/0009 (invalid)
- last data : 01/10/0007(invalid)
so, used browser.sleep(200) , it's works, but, there way do? 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());
i try splitting date string components , sending keys in "batches". implementation in quite broad form:
var action = browser.actions().mousemove(datainicio).click(); var randomdate = retornadataaleatoria(); var day = randomdate.slice(0, 2), month = randomdate.slice(3, 5), year = randomdate.slice(6, 10); action.sendkeys(day).sendkeys("/").sendkeys(month).sendkeys("/").sendkeys(year).perform();
if proven work, should change retornadataaleatoria
function , return array of parts of date delimiters can simplify sending keys step without needing slice string pieces:
var randomdateparts = retornadataaleatoria(); (var = 0; < randomdateparts; i++) { action = action.sendkeys(randomdateparts[i]); } action.perform();
you can add custom sleep()
action between every sendkeys()
deliberately slow down, having small delay between next batch of keys, see:
and, can slow protractor down entirely (probably idea debugging only):
Comments
Post a Comment