paulotarcio paulotarcio - 3 months ago 11
Javascript Question

How Can I wait to an element to appears using protractor and my file conf?

I'm trying to using protractor to wait to my input 'Username' to appears and then insert value on it. How Can I do it?

browser.get('http://localhost:5555/#');
var login = browser.driver.findElement(by.id('Username'));

Answer

Use Expected Conditions to wait for certain conditions, i.e. for an element to be present or visible. Use sendKeys to fill an input.

var login = element(by.id('Username'));
var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(login)).then(function() {
    login.sendKeys('myuser');
});

This belongs in your spec, not your config.