How to tell protractor to wait for each command for 3 seconds



  • I am running angular e2e scripts.

    I am adding explicit wait for every element.

    Instead, is it possible to tell protractor to delay 3 seconds for every command?



  • I think you can use the implicitlyWait option, although it has been removed from the Protractor documentation:

    onPrepare: function(){
        browser.manage().timeouts().implicitlyWait(3000);
    },
    

    Code example from: https://stackoverflow.com/questions/33299567/where-to-put-implicitlywait-in-protractor

    Read this!!!: Is it a bad practice to use implicit wait in Selenium Webdriver? Should one use only explicit wait?

    Alternatively:

    Wrap your driver/browser in your own helper class and implement your own "findElement()" method which always does an explicitWait.

    My pageObjects action methods start with a wait for the first element and then expect the other elements to be there:

        internal string ActionOnPage() {
            wait.ForElement(By.Id("uniqueid1")).SendKeys("sometext");
            driver.FindElement(By.Id("uniqueid2")).Click();
        }
    

    This wait.ForElement() is just a wrapper around the driver:

        public IWebElement ForElement(By by, int seconds = 10)
        {
            var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(seconds));
            return wait.Until(f => f.FindElement(by));
        }
    

    The example is in C#, but I think it translates to JavaScript/Protractor



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2