/// <summary> /// Executes the event. /// </summary> /// <param name="eventName">Name of the event to fire.</param> /// <param name="eventProperties"></param> /// <param name="WaitForEventToComplete"></param> private void ExecuteEvent(string eventName, NameValueCollection eventProperties, bool WaitForEventToComplete) { var creator = new JSEventCreator(ElementReference, ClientPort); var command = creator.CreateEvent(eventName, eventProperties, WaitForEventToComplete); ClientPort.WriteAndReadAsBool(command); Thread.Sleep(30); }
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> /// Gets the element by property. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <returns>Returns the element that is returned by the specified property</returns> public JSElement GetElementByProperty(string propertyName) { if (string.IsNullOrEmpty(propertyName)) { throw new ArgumentNullException("propertyName"); } var elementvar = ClientPort.CreateVariableName(); var command = string.Format("{0}={1}.{2}; {0}!=null;", elementvar, ElementReference, propertyName); var exists = ClientPort.WriteAndReadAsBool(command); return(exists ? new JSElement(ClientPort, elementvar) : null); }
public bool IsElementReferenceStillValid() { if (UtilityClass.IsNullOrEmpty(ElementReference)) { return(false); } // Note: We exclude elements that might appear as root elements from this check since we cannot verify them. const string excludedTags = "! HTML HEAD BODY TITLE LINK META SCRIPT STYLE BASE"; var command = string.Format("({0} != undefined && {0} != null) && ({0}.offsetParent != null || '{1}'.indexOf({0}.tagName.toUpperCase())> -1); ", ElementReference, excludedTags); return(ClientPort.WriteAndReadAsBool(command)); }
public bool ContainsText(string text) { try { var script = string.Format("{0}.body.innerHTML.indexOf('{1}')>-1;", JavaScriptVariableName, text); return(ClientPort.WriteAndReadAsBool(script)); } catch (JavaScriptException e) { Logger.LogDebug("ContainsText: " + e); return(false); } }
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); }
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); }
private bool IsReferenceEqual(string left, string right) { return(ClientPort.WriteAndReadAsBool("{0}=={1};", left, right)); }