Exemplo n.º 1
0
        public WebElement FindElement(ByMethod method, string selector)
        {
            WebElement result = null;

            if (_driver.FindElements(GetBy(method, selector)).Count > 0)
            {
                result = new WebElement(_driver.FindElement(GetBy(method, selector)));
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize a new instance of <see cref="TargetAttribute"/>
        /// </summary>
        /// <param name="by">Define the method used to locate the element</param>
        /// <param name="value">The By value</param>
        public TargetAttribute(ByMethod by, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException(nameof(value), ExceptionMessages.ArgumentCannotBeNullOrEmpty);
            }

            ByMethod = by;
            Value    = value;
        }
Exemplo n.º 3
0
        public List <WebElement> FindElements(ByMethod method, string selector)
        {
            var result = new List <WebElement>();

            foreach (IWebElement element in _driver.FindElements(GetBy(method, selector)))
            {
                result.Add(new WebElement(element));
            }
            return(result);
        }
Exemplo n.º 4
0
        public void AllByMethodsCanMapToTarget(ByMethod byMethod)
        {
            // arrange
            var fixture    = new Fixture();
            var targetName = fixture.Create <string>();
            var sut        = new TargetAttribute(byMethod, fixture.Create <string>());
            // act
            var actual = sut.CreateTarget(targetName);

            // arrange
            Assert.NotNull(actual);
            Assert.Equal(actual.Name, targetName);
        }
Exemplo n.º 5
0
        public static OpenQA.Selenium.By GetBy(ByMethod method, string selector)
        {
            switch (method)
            {
            case ByMethod.Id:
                return(By.Id(selector));

            case ByMethod.ClassName:
                return(By.ClassName(selector));

            case ByMethod.CssSelector:
                return(By.CssSelector(selector));

            case ByMethod.XPath:
                return(By.XPath(selector));

            default:
                return(null);
            }
        }
Exemplo n.º 6
0
		public List<WebElement> FindElements(ByMethod method, string selector)
		{
			var result = new List<WebElement>();
			foreach (IWebElement element in _element.FindElements(GetBy(method, selector)))
			{
				result.Add(new WebElement(element));
			}
			return result;
		}
Exemplo n.º 7
0
		public WebElement FindElement(ByMethod method, string selector)
		{
			WebElement result = null;
			if (_element.FindElements(GetBy(method, selector)).Count > 0)
			{
				result = new WebElement(_element.FindElement(GetBy(method, selector)));
			}
			return result;
		}
Exemplo n.º 8
0
 public FindBy(ByMethod method, string selector)
 {
     Method   = method;
     Selector = selector;
 }
Exemplo n.º 9
0
		public static OpenQA.Selenium.By GetBy(ByMethod method, string selector)
		{
			switch (method)
			{
				case ByMethod.Id:
					return By.Id(selector);
				case ByMethod.ClassName:
					return By.ClassName(selector);
				case ByMethod.CssSelector:
					return By.CssSelector(selector);
				case ByMethod.XPath:
					return By.XPath(selector);
				default:
					return null;
			}
		}
Exemplo n.º 10
0
		public FindBy(ByMethod method, string selector)
		{
			Method = method;
			Selector = selector;
		}