Custom Sleep function in C# for Selenium

Instead of using C#’s Thread.sleep functionality we can use the same but through another class

All we have to do is call Extra.Sleep(2000) in our Selenium Code and the only one prerequisite is we need to call the namespace in the functionality

//Static Class
public static class Extra
{  
// Extra.Sleep(2000) - will wait for 2 seconds
       public static void Sleep(int milliseconds)
        {
            System.Threading.Thread.Sleep(milliseconds);
        }
 }

 

You may also like...