Пример #1
0
        public static async Task<bool> hiveWaitUntilValueEquals<T>(this ChromeSession s, string key, T value, int timeout = 1000) where T : struct
        {
            return await asyncSpinlock.WaitUntil(async () =>
            {
                try
                {
                    return value.Equals(await s.EvalValue<T>(string.Format(hiveGetString, key)));
                }
                catch (Exception)
                {
                    return false;
                }
            }, timeout);

        }
Пример #2
0
        public static async Task<T> hiveWaitUntilGetValue<T>(this ChromeSession s, string key, int timeout = 1000) where T : struct
        {
            T result = default(T);
            if (await asyncSpinlock.WaitUntil(async () =>
             {
                 try
                 {

                     result = await s.EvalValue<T>(string.Format(hiveGetString, key));
                     return true;
                 }
                 catch (Exception)
                 {
                     return false;
                 }
             },timeout))
            {
                return result;
            }
            throw new TimeoutException("The desired response was not ready.");

        }
Пример #3
0
 public static async Task<T> hiveGetValue<T>(this ChromeSession s, string key) where T : struct
 {
     return await s.EvalValue<T>(string.Format(hiveGetString, key));
 }
Пример #4
0
 public static async Task<T> hiveSetValue<T>(this ChromeSession s, string key, T value) where T : struct
 {
     return await s.EvalValue<T>(string.Format(hiveSetString, key, Newtonsoft.Json.JsonConvert.SerializeObject(value)));
 }