Ejemplo n.º 1
0
 /// <summary>
 /// Clicks on multiple random elements in list
 /// </summary>
 /// <param name="elements">Any HTML element</param>
 public static void ClickRandomElements(this IList <IWebElement> elements)
 {
     foreach (var item in elements)
     {
         if (SafeRandom.Next(0, 100) % 2 == 0)
         {
             item.ClickElement();
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Enters date within given limit
 /// </summary>
 /// <param name="element">Inputs or other clearable element</param>
 /// <param name="minDays">Minimum limit to change date, if zero date can be today</param>
 /// <param name="maxDays">Maximum limit to change date</param>
 /// <param name="clear">Should be element cleared before entering the date?</param>
 public static void EnterRandomDate(this IWebElement element, int minDays, int maxDays, bool clear = true)
 {
     if (clear)
     {
         element.EnterText(DateTime.Today.AddDays(SafeRandom.Next(minDays, maxDays)).ToShortDateString());
     }
     else
     {
         element.SendKeys(DateTime.Today.AddDays(SafeRandom.Next(minDays, maxDays)).ToShortDateString());
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Enters path to .jpg or .png image in "/Testing files" directory
        /// This directory must be created manualy and some images must be present there
        /// </summary>
        /// <param name="element">Uploead file/image button</param>
        public static void EnterRandomImage(this IWebElement element)
        {
            var image = Path.GetFullPath(Directory.GetFiles(@"Testing Files").Where(r => r.Contains(".jpg") || r.Contains(".png")).OrderBy(i => SafeRandom.Next()).First());

            element.SendKeys(image);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Selects random element in selectbox by index within limit in selectbox
 /// </summary>
 /// <param name="element">Select element</param>
 /// <param name="min">Minimum index of element</param>
 /// <param name="max">Maximum index of element</param>
 public static void SelectRandomElement(this IWebElement element, int min, int max)
 {
     new SelectElement(element).SelectByIndex(SafeRandom.Next(min, max));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Selects random option in select box by index
 /// </summary>
 /// <param name="element">Select element</param>
 public static void SelectRandomElement(this IWebElement element)
 {
     new SelectElement(element).SelectByIndex(SafeRandom.Next(1, element.FindElements(By.TagName("option")).Count));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Clicks on random element in list with minimum and maximum position in list
        /// </summary>
        /// <param name="elements">Any HTML elements</param>
        /// <param name="min">Minimum position of element in list</param>
        /// <param name="max">Maximum position of element in list</param>
        public static void ClickRandomElement(this IList <IWebElement> elements, int max, int min = 0)
        {
            IWebElement element = elements[SafeRandom.Next(min, max)];

            element.ClickElement();
        }