示例#1
0
		public void SelectByValue(string value, SelectByValueType strict = SelectByValueType.Equal)
		{
			IWebElement listDropDown = _driver.FindElement(_listDropDownId);

			IWebElement firstElement = _driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[1]"));
			IWebElement lastElement = _driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[last()]"));

			Point fistElementStart = firstElement.Location;
			Point lastElementStart = lastElement.Location;
			//_driver.FindElement(_arrowId).FindElement(By.XPath("./parent::*")).Click();
			_driver.FindElement(_arrowId).Click();

			BasePage.WaitTillStopMoving(_driver, firstElement, fistElementStart);
			BasePage.WaitTillStopMoving(_driver, lastElement, lastElementStart);

			fistElementStart = firstElement.Location;
			lastElementStart = lastElement.Location;
			if (strict == SelectByValueType.Equal)
			{
				_driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[text() = '" + value + "']")).
								ScrollIntoView().
								Click();
			}
			else if (strict == SelectByValueType.Contains)
			{
				_driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[contains(text(), '" + value + "')]")).ScrollIntoView().
					Click();
			}
			else
			{
				throw new Exception("Wrong SelectByValueType");
			}

			try
			{
				BasePage.WaitTillStopMoving(_driver, firstElement, fistElementStart);
				BasePage.WaitTillStopMoving(_driver, lastElement, lastElementStart);
			}
			catch (StaleElementReferenceException)
			{
				Trace.WriteLine(BasePage.TraceLevelElement + "StaleElementReferenceException in SelectByValue of '" + value + "'");
			}

		}
示例#2
0
        public void SelectByValue(string value, SelectByValueType strict = SelectByValueType.Equal)
        {
            IWebElement listDropDown = _driver.FindElement(_listDropDownId);

            IWebElement firstElement = _driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[1]"));
            IWebElement lastElement  = _driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[last()]"));

            Point fistElementStart = firstElement.Location;
            Point lastElementStart = lastElement.Location;

            //_driver.FindElement(_arrowId).FindElement(By.XPath("./parent::*")).Click();
            _driver.FindElement(_arrowId).Click();

            BasePage.WaitTillStopMoving(_driver, firstElement, fistElementStart);
            BasePage.WaitTillStopMoving(_driver, lastElement, lastElementStart);

            fistElementStart = firstElement.Location;
            lastElementStart = lastElement.Location;
            if (strict == SelectByValueType.Equal)
            {
                _driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[text() = '" + value + "']")).
                Click();
            }
            else if (strict == SelectByValueType.Contains)
            {
                _driver.FindElement(By.XPath("//*[@id='" + listDropDown.GetAttribute("id") + "']//li[contains(text(), '" + value + "')]")).
                Click();
            }
            else
            {
                throw new Exception("Wrong SelectByValueType");
            }

            try
            {
                BasePage.WaitTillStopMoving(_driver, firstElement, fistElementStart);
                BasePage.WaitTillStopMoving(_driver, lastElement, lastElementStart);
            }
            catch (StaleElementReferenceException)
            {
                Trace.WriteLine(BasePage.TraceLevelElement + "StaleElementReferenceException in SelectByValue of '" + value + "'");
            }
        }
示例#3
0
		public static void SelectByValue (IWebDriver driver, By arrowId, By listDropDownId, string value, SelectByValueType strict = SelectByValueType.Equal)
		{
			Trace.WriteLine(BasePage.TraceLevelElement + "Select '" + value + "' in the list '" + listDropDownId + "'");
			new SlidingSelect(driver, arrowId, listDropDownId).SelectByValue(value, strict);
		}
示例#4
0
 public static void SelectByValue(IWebDriver driver, By arrowId, By listDropDownId, string value, SelectByValueType strict = SelectByValueType.Equal)
 {
     Trace.WriteLine(BasePage.TraceLevelElement + "Select '" + value + "' in the list '" + listDropDownId + "'");
     new SlidingSelect(driver, arrowId, listDropDownId).SelectByValue(value, strict);
 }