Exemplo n.º 1
0
        private void ExtractPointData()
        {
            // Refreshing the DOM tree
            this.ActiveBrowser.RefreshDomTree();

            // Loading the tool tip div
            HtmlDiv tooltipDiv = this.Find.ByExpression <HtmlDiv>("tagName=div", "class=telerik-blazor k-animation-container k-chart-tooltip-wrapper");

            // Capturing the image
            var img = tooltipDiv.BaseElement.CaptureImage();

            // Using OCR to get text from image
            var imgText = Telerik.TestStudio.OCR.OcrManager.GetTextFromImageBytes(img.Image, false);

            // Parsing and adding captured data into list of objects
            this.DataPoints.Add(ProductPoint.Parse(imgText));
        }
Exemplo n.º 2
0
        // Method to parse text into ProductPoint
        public static ProductPoint Parse(string text)
        {
            var p = new ProductPoint();

            var strReader = new StringReader(text);

            while (true)
            {
                string line = strReader.ReadLine();

                if (line == null)
                {
                    break;
                }
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                line = line.TrimStart('=').TrimStart();
                string[] splitLine = line.Split(' ');

                if (line.StartsWith("AA"))
                {
                    p.AA = splitLine[splitLine.Length - 1];
                }
                else if (line.StartsWith("DM"))
                {
                    p.DM = splitLine[splitLine.Length - 1];
                }
                else if (line.StartsWith("SF"))
                {
                    p.SF = splitLine[splitLine.Length - 1];
                }
                else if (line.StartsWith("Revenue"))
                {
                    p.TotalRevenue = splitLine[splitLine.Length - 1];
                }
                else
                {
                    p.Category = line;
                }
            }
            return(p);
        }