コード例 #1
0
        public async Task <string> GetElementEffectiveStyle(string elementId, string property, CancellationToken cancellationToken = new CancellationToken())
        {
            var res = await WebView.CallFunction(atoms.GET_EFFECTIVE_STYLE, $"{{\"{Session.GetElementKey()}\":\"{elementId}\"}}, \"{property}\"", Session?.GetCurrentFrameId(), true, false, cancellationToken).ConfigureAwait(false);

            var value     = res?.Result?.Value as JToken;
            var exception = ResultValueConverter.ToWebBrowserException(value);

            if (exception != null)
            {
                throw exception;
            }
            return(ResultValueConverter.AsString(res?.Result?.Value));
        }
コード例 #2
0
        public async Task <string> GetElementTagName(string elementId, CancellationToken cancellationToken = new CancellationToken())
        {
            var func = "function(elem) { return elem.tagName.toLowerCase(); }";
            var res  = await WebView.CallFunction(func, $"{{\"{Session.GetElementKey()}\":\"{elementId}\"}}", Session?.GetCurrentFrameId(), true, false, cancellationToken).ConfigureAwait(false);

            var value     = res?.Result?.Value as JToken;
            var exception = ResultValueConverter.ToWebBrowserException(value);

            if (exception != null)
            {
                throw exception;
            }
            return(ResultValueConverter.AsString(res?.Result?.Value));
        }
コード例 #3
0
        public async Task <string> GetElementEffectiveStyle(string elementId, string property, CancellationToken cancellationToken = new CancellationToken())
        {
            var res = await webView.CallFunction(atoms.GET_EFFECTIVE_STYLE, $"{{\"{GetElementKey()}\":\"{elementId}\"}}, \"{property}\"", null, true, false, cancellationToken);

            return(ResultValueConverter.AsString(res?.Result?.Value));
        }
コード例 #4
0
        public async Task <string> GetElementAttribute(string elementId, string attributeName, CancellationToken cancellationToken = new CancellationToken())
        {
            var res = await WebView.CallFunction(atoms.GET_ATTRIBUTE, $"{{\"{Session.GetElementKey()}\":\"{elementId}\"}}, \"{attributeName}\"", Session?.GetCurrentFrameId(), true, false, cancellationToken).ConfigureAwait(false);

            return(ResultValueConverter.AsString(res?.Result?.Value)); // (res?.Result?.Value as JObject)?["value"]?.ToString();
        }