Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 // ReSharper disable once InconsistentNaming
 private bool CheckJSNodeVarExist() => JSHelper.IsVariableExist(NodeTab, _jsNodeVar);
Esempio n. 3
0
 internal string CreateJSNodeVar()
 => JSHelper.CreateUniqueProperty(_workDoc, _z.Rnd, JSNodesStore, JSValue.EmptyObject, configurable: JSBool.True, writable: JSBool.True, enumerable: JSBool.False);
Esempio n. 4
0
 public static void ReloadPage(Document doc) => JSHelper.Eval(doc, "window.location.reload(true);");