Beispiel #1
0
        public string GetPropertyValue(string propertyName)
        {
            var command = string.Format("{0}.{1};", DocumentReference, propertyName);

            if (propertyName == Document.ERROR_PROPERTY_NAME)
            {
                return(ClientPort.WriteAndReadIgnoreError(command));
            }

            return(ClientPort.WriteAndRead(command));
        }
Beispiel #2
0
        private bool Navigate(string action)
        {
            var ticks = Guid.NewGuid().ToString();

            ClientPort.Write("{0}.WatiNGoBackCheck='{1}';", ClientPort.DocumentVariableName, ticks);
            ClientPort.WriteAndRead(string.Format("{0}.home();true;", ClientPort.PromptName));
            ClientPort.Write("{0}.{1}();", BrowserVariableName, action);

            ClientPort.InitializeDocument();

            return(ClientPort.WriteAndReadAsBool("{0}.WatiNGoBackCheck!='{1}';", ClientPort.DocumentVariableName, ticks));
        }
        public bool IsLoading()
        {
            bool loading;

            switch (ClientPort.JavaScriptEngine)
            {
            case JavaScriptEngineType.WebKit:
                loading = ClientPort.WriteAndReadAsBool("{0}.readyState != 'complete';", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("{0}.readyState;", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("window.location.href");
                break;

            case JavaScriptEngineType.Mozilla:
                loading = ClientPort.WriteAndReadAsBool("{0}.webProgress.busyFlags!=0;", BrowserVariableName);
                break;

            default:
                throw new NotImplementedException();
            }

            return(loading);
        }
Beispiel #4
0
        public string GetStyleAttributeValue(string attributeName)
        {
            if (string.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentNullException("attributeName");
            }

            attributeName = UtilityClass.TurnStyleAttributeIntoProperty(attributeName);

            string attributeValue;

            if (attributeName == "cssText")
            {
                attributeValue = GetProperty("style." + attributeName);
            }
            else
            {
                attributeValue = ClientPort.WriteAndRead("{2}.defaultView.getComputedStyle({0},null).{1};", ElementReference, attributeName, ClientPort.DocumentVariableName);
            }

            return(string.IsNullOrEmpty(attributeValue) ? null : attributeValue);
        }
Beispiel #5
0
        public bool IsLoading()
        {
            bool loading;

            switch (ClientPort.JavaScriptEngine)
            {
            case JavaScriptEngineType.WebKit:
                loading = ClientPort.WriteAndReadAsBool("{0}.readyState != 'complete';", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("{0}.readyState;", ClientPort.DocumentVariableName);
                ClientPort.WriteAndRead("window.location.href");
                break;

            case JavaScriptEngineType.Mozilla:
                ClientPort.WriteAndRead(string.Format("{0}.home();true;", PromptName));
                loading = ClientPort.WriteAndReadAsBool("{0}.webProgress.busyFlags!=0;", BrowserVariableName);
                ClientPort.WriteAndRead(string.Format("if(typeof(w0)!=='undefined'){0}.enter(w0.content);true;", PromptName));
                break;

            default:
                throw new NotImplementedException();
            }

            return(loading);
        }
Beispiel #6
0
        /// <summary>
        /// Gets the property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns></returns>
        public string GetProperty(string propertyName)
        {
            var command = string.Format("{0}.{1};", ElementReference, propertyName);

            return(ClientPort.WriteAndRead(command));
        }
Beispiel #7
0
        public string GetAttribute(string attributeName)
        {
            var getAttributeWrite = string.Format("{0}.getAttribute(\"{1}\");", ElementReference, attributeName);

            return(ClientPort.WriteAndRead(getAttributeWrite));
        }