Exemplo n.º 1
0
        /// <summary>
        /// Gets a collection of elements by id.
        /// </summary>
        /// <param name="id">The id of the element.</param>
        /// <returns>Collection of elements for the given <paramref name="id"/>.</returns>
        protected IEnumerable <INativeElement> GetElementsByIdImpl(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            Initialize();

            if (!clientPort.HasJavaScriptSupportForQuerySelector)
            {
                var elementReference  = clientPort.CreateVariableName();
                var documentReference = GetDocumentReference(containerReference);
                var command           = string.Format("{0} = {1}.getElementById(\"{2}\"); {0} != null", elementReference, documentReference, id);
                if (clientPort.WriteAndReadAsBool(command))
                {
                    yield return(new JSElement(clientPort, elementReference));
                }
            }
            else
            {
                var command    = string.Format("{0}.querySelectorAll(\"[Id='{1}']\")", containerReference, id);
                var ffElements = GetElementArrayEnumerator(command);
                foreach (var ffElement in ffElements)
                {
                    yield return(ffElement);
                }
            }
        }
Exemplo n.º 2
0
        public static IEnumerable<JSElement> ElementArrayEnumerator(string getElementsCommand, ClientPortBase clientPort)
        {
            var ElementArrayName = clientPort.CreateVariableName();

            var numberOfElements = GetNumberOfElements(getElementsCommand, clientPort, ElementArrayName);

            try
            {
                for (var index = 0; index < numberOfElements; index++)
                {
                    var indexedElementVariableName = string.Concat(ElementArrayName, "[", index.ToString(), "]");
                    var ffElement = new JSElement(clientPort, indexedElementVariableName);

                    yield return ffElement;
                }
            }
            finally
            {
                DeleteElementArray(ElementArrayName, clientPort);
            }
        }
Exemplo n.º 3
0
        public static IEnumerable <JSElement> ElementArrayEnumerator(string getElementsCommand, ClientPortBase clientPort)
        {
            var ElementArrayName = clientPort.CreateVariableName();

            var numberOfElements = GetNumberOfElements(getElementsCommand, clientPort, ElementArrayName);

            try
            {
                for (var index = 0; index < numberOfElements; index++)
                {
                    var indexedElementVariableName = string.Concat(ElementArrayName, "[", index.ToString(), "]");
                    var ffElement = new JSElement(clientPort, indexedElementVariableName);

                    yield return(ffElement);
                }
            }
            finally
            {
                DeleteElementArray(ElementArrayName, clientPort);
            }
        }