public bool TryGetHtmlNodeByXPath(string xPath, out HtmlNode htmlNode, string contextJSNodeVar = JSObject.DocumentElement, int attempts = 20, int delay = 500) { Document doc = _workDoc; string jsXPathResultVar = CreateJSNodeVar(); for (int i = 0; i < attempts; i++) { JSHelper.GetXPathResult(doc, jsXPathResultVar, xPath, contextJSNodeVar); if (CheckResult(doc, jsXPathResultVar + ".singleNodeValue", out htmlNode)) { return(true); } Thread.Sleep(delay); } htmlNode = null; return(false); }
// ReSharper disable once InconsistentNaming private bool CheckJSNodeVarExist() => JSHelper.IsVariableExist(NodeTab, _jsNodeVar);
internal string CreateJSNodeVar() => JSHelper.CreateUniqueProperty(_workDoc, _z.Rnd, JSNodesStore, JSValue.EmptyObject, configurable: JSBool.True, writable: JSBool.True, enumerable: JSBool.False);
public static void ReloadPage(Document doc) => JSHelper.Eval(doc, "window.location.reload(true);");