Represents a single DOM element in a browser
This class wraps Selenium's IWebElement to provide additional capabilities for logging, automatic waiting and more.
Inheritance: ElementsContainer, IWebElement, IWrapsElement
示例#1
0
 public Frame(BrowserElement frameElement)
     : base(frameElement.Description)
 {
     _frameElement = frameElement;
     var browser = _frameElement.DOMRoot.Browser;
     _webDriver = browser.GetWebDriver();
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frame"/> class representing the frame element specified
        /// </summary>
        /// <param name="frameElement">The BrowserElement of the frame element</param>
        public Frame(BrowserElement frameElement)
            : base(frameElement.Description)
        {
            _frameElement = frameElement;
            var browser = _frameElement.DOMRoot.Browser;

            _webDriver = browser.GetWebDriver();
        }
示例#3
0
        public void DragAndDrop(BrowserElement target)
        {
            Logger.WriteLine("Drag element '{0}' to '{1}'", Description, target.Description);
            var targetWebElement = target.WebElement;
            var action           = CreateActionsSequence();
            var dragAndDrop      = action.MoveToElement(WebElement).DragAndDrop(WebElement, targetWebElement).Build();

            dragAndDrop.Perform();
        }
示例#4
0
        /// <summary>
        /// Drags the current element onto the target element
        /// </summary>
        /// <param name="target">The target element to drop the current element onto</param>
        /// <exception cref="ArgumentNullException"><paramref name="target"/> is null</exception>
        public void DragAndDrop(BrowserElement target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            Logger.WriteLine("Drag element '{0}' to '{1}'", Description, target.Description);
            var targetWebElement = target.WebElement;
            var action           = CreateActionsSequence();
            var dragAndDrop      = action.MoveToElement(WebElement).DragAndDrop(WebElement, targetWebElement).Build();

            dragAndDrop.Perform();
        }
示例#5
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="otherElement">Other object from which to copy the properties into the new object</param>
 protected BrowserElement(BrowserElement otherElement)
     : this(otherElement, otherElement.Description)
 {
 }
示例#6
0
 /// <summary>
 /// Constructs a new instance of <see cref="BrowserElement"/> by copying its properties, except of its description from another element
 /// </summary>
 /// <param name="otherElement">The existing element to copy its properties from</param>
 /// <param name="description">The new description to use for the new object</param>
 /// <exception cref="ArgumentNullException"><paramref name="otherElement"/> is null</exception>
 protected BrowserElement(BrowserElement otherElement, string description)
     : this(SafeGetDOMRoot(otherElement, "otherElement"), () => otherElement.WebElement, description)
 {
 }
示例#7
0
        /// <summary>
        /// Drags the current element onto the target element
        /// </summary>
        /// <param name="target">The target element to drop the current element onto</param>
        /// <exception cref="ArgumentNullException"><paramref name="target"/> is null</exception>
        public void DragAndDrop(BrowserElement target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            Logger.WriteLine("Drag element '{0}' to '{1}'", Description, target.Description);
            var targetWebElement = target.WebElement;
            var action = CreateActionsSequence();
            var dragAndDrop = action.MoveToElement(WebElement).DragAndDrop(WebElement, targetWebElement).Build();
            dragAndDrop.Perform();
        }
示例#8
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="otherElement">Other object from which to copy the properties into the new object</param>
 protected BrowserElement(BrowserElement otherElement)
     : this(otherElement, otherElement.Description)
 {
 }
示例#9
0
 /// <summary>
 /// Constructs a new instance of <see cref="BrowserElement"/> by copying its properties, except of its description from another element
 /// </summary>
 /// <param name="otherElement">The existing element to copy its properties from</param>
 /// <param name="description">The new description to use for the new object</param>
 /// <exception cref="ArgumentNullException"><paramref name="otherElement"/> is null</exception>
 protected BrowserElement(BrowserElement otherElement, string description)
     : this(SafeGetDOMRoot(otherElement, "otherElement"), () => otherElement.WebElement, description)
 {
 }