Example #1
0
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 private WaitAndRefresh(IWebLocator locator) :
     base(locator)
 {
     RefreshSeconds    = 3;
     TimeoutSeconds    = null;
     AdditionalSeconds = 0;
 }
Example #2
0
 /// <summary>
 /// Private constructor.
 /// (Use static builder methods to construct.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="index">The index of the option to select. Use if not null.</param>
 /// <param name="partialMatch">If true, do partial match on option text. Only applicable for selection by text.</param>
 /// <param name="text">The text of the option to select. Use if not null.</param>
 /// <param name="value">The text of the option to select. Use if not null.</param>
 private Select(IWebLocator locator, int?index = null, bool partialMatch = false, string text = null, string value = null)
     : base(locator)
 {
     Index        = index;
     PartialMatch = partialMatch;
     Text         = text;
     Value        = value;
 }
Example #3
0
 /// <summary>
 /// Private constructor.
 /// (Use static builder methods to construct.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="keystrokes">The keystrokes (e.g., text) to send.</param>
 private SendKeys(IWebLocator locator, string keystrokes) : base(locator)
 {
     Clear          = true;
     FinalElement   = null;
     FinalEnter     = false;
     Keystrokes     = keystrokes;
     Private        = false;
     UseClearMethod = false;
 }
        public void SetUpLocator()
        {
            var element = new Mock <IWebElement>();

            WebDriver.Setup(x => x.FindElements(It.IsAny <By>())).Returns(new List <IWebElement> {
                element.Object
            }.AsReadOnly());
            WebDriver.Setup(x => x.FindElement(It.IsAny <By>())).Returns(element.Object);
            Locator = new WebLocator("description", By.Id("id"));
        }
Example #5
0
 /// <summary>
 /// Constructs the Question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static Existence Of(IWebLocator locator) => new Existence(locator);
 /// <summary>
 /// Constructs the question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static SelectOptionsAvailable For(IWebLocator locator) => new SelectOptionsAvailable(locator);
Example #7
0
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private Existence(IWebLocator locator) : base(locator)
 {
 }
Example #8
0
 /// <summary>
 /// Constructs the question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static EnabledState Of(IWebLocator locator) => new EnabledState(locator);
Example #9
0
 /// <summary>
 /// Constructs the Question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static Count Of(IWebLocator locator) =>
 new Count(locator);
 /// <summary>
 /// Constructs the Question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static SelectedOptionText Of(IWebLocator locator) => new SelectedOptionText(locator);
Example #11
0
 /// <summary>
 /// Constructs the task object to select by value.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="value">The value of the option to select.</param>
 /// <returns></returns>
 public static Select ByValue(IWebLocator locator, string value) =>
 new Select(locator, value: value);
 /// <summary>
 /// Constructs a HtmlAttributeList question for the "value" attribute.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static HtmlAttributeList For(IWebLocator locator) => HtmlAttributeList.For(locator, Value);
 /// <summary>
 /// Constructs the question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="named">The attribute name.</param>
 /// <returns></returns>
 public static HtmlAttributeList For(IWebLocator locator, string named) => new HtmlAttributeList(locator, named);
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="propertyName">The attribute name.</param>
 protected HtmlAttributeList(IWebLocator locator, string propertyName) : base(locator, propertyName)
 {
 }
Example #15
0
 /// <summary>
 /// Constructs the Question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static Classes Of(IWebLocator locator) => new Classes(locator);
Example #16
0
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private Classes(IWebLocator locator) : base(locator)
 {
 }
Example #17
0
 /// <summary>
 /// Constructs the task object to select by index.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="index">The index of the option to select.</param>
 /// <returns></returns>
 public static Select ByIndex(IWebLocator locator, int index) =>
 new Select(locator, index: index);
Example #18
0
 /// <summary>
 /// Constructs the Task.
 /// </summary>
 /// <param name="locator">The locator for whose appearance to wait.</param>
 /// <returns></returns>
 public static WaitAndRefresh For(IWebLocator locator) => new WaitAndRefresh(locator);
Example #19
0
 /// <summary>
 /// Constructs the task object to select by text.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <param name="text">The text of the option to select.</param>
 /// <param name="partialMatch">If true, do partial match on option text.</param>
 /// <returns></returns>
 public static Select ByText(IWebLocator locator, string text, bool partialMatch = false) =>
 new Select(locator, text: text, partialMatch: partialMatch);
 /// <summary>
 /// Constructs the question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static JavaScriptText Of(IWebLocator locator) => new JavaScriptText(locator);
Example #21
0
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private Text(IWebLocator locator) : base(locator)
 {
 }
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private SelectedOptionText(IWebLocator locator) : base(locator)
 {
 }
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private JavaScriptText(IWebLocator locator) : base(locator)
 {
 }
Example #24
0
 /// <summary>
 /// Constructs the question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static Text Of(IWebLocator locator) => new Text(locator);
Example #25
0
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private Count(IWebLocator locator) : base(locator)
 {
 }
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private SelectedState(IWebLocator locator) : base(locator)
 {
 }
Example #27
0
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private EnabledState(IWebLocator locator) : base(locator)
 {
 }
 /// <summary>
 /// Constructs the question.
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 /// <returns></returns>
 public static SelectedState Of(IWebLocator locator) => new SelectedState(locator);
        /// <summary>
        /// Finds all Web elements on the page matching the provided locator and gets a value from each.
        /// </summary>
        /// <param name="actor">The Screenplay Actor.</param>
        /// <param name="driver">The Selenium web driver.</param>
        /// <param name="locator">Locator used to find Web elements.</param>
        /// <param name="getValue">The method used to obtain the desired value from each Web element.</param>
        /// <returns>A list of string values from each Web element found.</returns>
        public static IEnumerable <string> GetValues(IActor actor, IWebDriver driver, IWebLocator locator, Func <IWebElement, string> getValue)
        {
            actor.WaitsUntil(Existence.Of(locator), IsEqualTo.True());
            var elements = driver.FindElements(locator.Query);
            var strings  = from e in elements select getValue(e);

            // ToList() will avoid lazy evaluation
            return(strings.ToList());
        }
 /// <summary>
 /// Private constructor.
 /// (Use static methods for public construction.)
 /// </summary>
 /// <param name="locator">The target Web element's locator.</param>
 private SelectOptionsAvailable(IWebLocator locator) : base(locator)
 {
 }