public async Task <WebPoint> ScrollElementRegionIntoView(string elementId, WebRect region, bool center, string clickableElementId = null, CancellationToken cancellationToken = new CancellationToken())
        {
            var regionOffset = await ScrollElementRegionIntoViewHelper(elementId, region, center, clickableElementId, cancellationToken);

            if (Session?.Frames?.Any() == true)
            {
                var func =
                    "function(xpath) {" +
                    "  return document.evaluate(xpath, document, null," +
                    "      XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;" +
                    "}";
                foreach (var frame in Session.Frames)
                {
                    var args = $"\"//*[@cd_frame_id_ = '{frame.CromeFrameId}']\"";
                    var res  = await webView.CallFunction(func, args);

                    //todo
                    var frameElementId = res.Result?.Value?.ToString();
                    var border         = await GetElementBorder(frameElementId, cancellationToken);

                    var regionOffset2 = region.Offset(border.X, border.Y);

                    var location = await ScrollElementRegionIntoViewHelper(frameElementId, new WebRect(regionOffset, region.Size()), center, frameElementId, cancellationToken);

                    return(location);
                }
            }
            return(regionOffset);
        }
        public async Task <WebPoint> ScrollElementRegionIntoViewHelper(string elementId, WebRect region, bool center = true, string clickableElementId = null, CancellationToken cancellationToken = new CancellationToken())
        {
            var res = await webView.CallFunction(atoms.GET_LOCATION_IN_VIEW, $"{{\"{GetElementKey()}\":\"{elementId}\"}}, {center.ToString().ToLower()}, {WebRectToJsonString(region)}", null, true, false, cancellationToken);

            var location = ResultValueConverter.ToWebPoint(res?.Result?.Value);

            if (clickableElementId != null)
            {
                var middle      = location.Offset(region.Width / 2, region.Height / 2);
                var isClickable = await VerifyElementClickable(clickableElementId, middle);

                if (!isClickable)
                {
                    return(null);
                }
            }
            return(location);
        }
 public string ElementJsonString(WebRect elementId)
 {
     return($"{{\"{GetElementKey()}\":\"{elementId}\"}}");
 }
 public string WebRectToJsonString(WebRect rect)
 {
     return($"{{\"left\": {rect.X}, \"top\": {rect.Y}, \"width\": {rect.Width}, \"height\": {rect.Height} }}");
 }