Example #1
0
        /// <summary>
        /// This changes/pins the java script variable name <see cref="ElementReference"/> which is used to
        /// execute commands on FireFox.
        /// </summary>
        public void Pin()
        {
            var elementVariableName = ClientPort.CreateVariableName();

            ClientPort.Write("{0}={1};", elementVariableName, ElementReference);

            ElementReference = elementVariableName;
        }
Example #2
0
 public void RunScript(string scriptCode, string language)
 {
     try
     {
         ClientPort.Write(scriptCode);
     }
     catch (FireFoxException e)
     {
         throw new RunScriptException(e);
     }
 }
        private bool Navigate(string action)
        {
            var ticks = Guid.NewGuid().ToString();

            ClientPort.Write("{0}.WatiNGoBackCheck='{1}';", ClientPort.DocumentVariableName, ticks);
            ClientPort.Write("{0}.{1}();", BrowserVariableName, action);

            ClientPort.InitializeDocument();

            return(ClientPort.WriteAndReadAsBool("{0}.WatiNGoBackCheck!='{1}';", ClientPort.DocumentVariableName, ticks));
        }
        /// <summary>
        /// Load a URL into the document. see: http://developer.mozilla.org/en/docs/XUL:browser#m-loadURI
        /// </summary>
        /// <param name="url">The URL to laod.</param>
        /// <param name="waitForComplete">If false, makes to execution of LoadUri asynchronous.</param>
        protected override void LoadUri(Uri url, bool waitForComplete)
        {
            var command = string.Format("{0}.loadURI(\"{1}\");", BrowserVariableName, url.AbsoluteUri);

            if (!waitForComplete)
            {
                command = JSUtils.WrapCommandInTimer(command);
            }

            ClientPort.Write(command);
        }
Example #5
0
        /// <summary>
        /// Sets the property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="value">The value.</param>
        public void SetProperty(string propertyName, string value)
        {
            if (SetPropertyTransformations.ContainsKey(propertyName))
            {
                value = SetPropertyTransformations[propertyName].Invoke(value);
            }

            var command = string.Format("{0}.{1} = {2};", ElementReference, propertyName, value);

            ClientPort.Write(command);
        }
Example #6
0
        /// <summary>
        /// Load a URL into the document. see: http://developer.mozilla.org/en/docs/XUL:browser#m-loadURI
        /// </summary>
        /// <param name="url">The URL to laod.</param>
        /// <param name="waitForComplete">If false, makes to execution of LoadUri asynchronous.</param>
        protected override void LoadUri(Uri url, bool waitForComplete)
        {
            var command = string.Format("{0}.loadURI(\"{1}\");", ClientPort.PromptName, url.AbsoluteUri);

            //var command = string.Format("w0.content.location.href = \"{0}\"; }}",url.AbsoluteUri);
            if (!waitForComplete)
            {
                command = JSUtils.WrapCommandInTimer(command);
            }

            ClientPort.Write(command);
        }
 /// <summary>
 /// Reloads this instance.
 /// </summary>
 /// <param name="forceGet">When it is <c>true</c>, causes the page to always be reloaded from the server.
 /// If it is <c>false</c>, the browser may reload the page from its cache.</param>
 private void Reload(bool forceGet)
 {
     ClientPort.Write("{0}.location.reload({1});", FireFoxClientPort.WindowVariableName, forceGet.ToString().ToLower());
 }
 /// <summary>
 /// Closes the browser.
 /// </summary>
 public void Close()
 {
     ClientPort.Write("{0}.close()", FireFoxClientPort.WindowVariableName);
 }
Example #9
0
 /// <summary>
 /// Executes a method with no parameters.
 /// </summary>
 /// <param name="methodName">Name of the method to execute.</param>
 public void ExecuteMethod(string methodName)
 {
     ClientPort.Write("{0}.{1}();", ElementReference, methodName);
 }
Example #10
0
 public void SetAttribute(string attributeName, string value)
 {
     ClientPort.Write("{0}.setAttribute(\"{1}\", \"{2}\");", ElementReference, attributeName, value);
 }