public static void LogOn(this IActionSyntaxProvider I, string userName, string password)
 {
     I.Open(UrlHelper.BaseUrl + "users/account/LogOn");
     I.Expect.Url(x => x.LocalPath.Contains("LogOn"));
     I.Enter(EnvironmentSettings.TestAccountName).In("#SignIn_UserNameOrEmail");
     I.Enter(EnvironmentSettings.TestAccountPassword).In("#SignIn_Password");
     I.Click("#signin-link");
     I.Wait(1);
 }
Ejemplo n.º 2
0
        public static IActionSyntaxProvider WaitForAjaxFinish(this IActionSyntaxProvider I, int timeout = 30000)
        {
            Log.Debug("Enter WaitForAjaxFinish");
            var start = DateTime.Now;
            var end   = start.AddMilliseconds(timeout);

            // wait for the script being triggered.
            I.Wait(TimeSpan.FromMilliseconds(300));

            var endCount = 0;

            var count = 100;

            while (DateTime.Now < end && count > endCount)
            {
                try
                {
                    I.Wait(TimeSpan.FromMilliseconds(100));
                    count = Int32.Parse(I.ExecuteScript("return $.active").ToString());
                }
                catch (UnhandledAlertException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Object reference not set to an instance of an object") ||
                        ex.Message.Contains("$ is not defined"))
                    {
                        count = 0;
                    }
                }
            }

            // wait for any javascript execution after ajax executed
            I.Wait(TimeSpan.FromMilliseconds(300));

            Log.Debug("Leave WaitForAjaxFinish. Waited " + (DateTime.Now - start).TotalMilliseconds);

            return(I);
        }
        public static void UploadPackageUsingUI(this IActionSyntaxProvider I, string fullPackagePath)
        {
            // Navigate to the Upload Package page.  This will fail if the user never uploaded the previous package, hence the error handling.
            I.Open(string.Format(UrlHelper.UploadPageUrl));
            try
            {
                I.Expect.Url(x => x.AbsoluteUri.Contains("/packages/manage/Upload"));
            }
            catch
            {
                I.Click("a[class='cancel']");
            }

            // Upload the package.
            I.Click("input[name='UploadFile']");
            I.Wait(5);
            I.Type(fullPackagePath);
            I.Press("{ENTER}");
            I.Wait(5);
            I.Click("input[value='Upload']");
        }