'unable to send key data to input text + protractor

I have a field with id and want to input text to the field. This field is part of a formdata. I have tried with ng_model locator as well as id locator. I have also tried browser.wait like below but it does not get into the below block even though the page is already loaded.

browser.wait(EC.visibilityOf(element-locator), 1000).then(function(){
     
     console.log("aim here");
 element-locator.sendKeys("sometext");
     
    });


Solution 1:[1]

there might be chance that element is not visible within the time mentioned. Increase the timeout or try with presenceOf

browser.wait(EC.visibilityOf(element-locator), 5000).then(function(){
     
 console.log("aim here");
 element-locator.sendKeys("sometext");
     
});

Or

browser.wait(EC.presenceOf(element-locator), 5000).then(flag=>{
 if(flag){
  console.log("aim here");
  element-locator.sendKeys("sometext");
 }else{
  console.log("element not being diplayed");  
 }             
});

Cheers!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dheeraj