Ejemplo n.º 1
0
 public ConsoleDebugger(IDataContext data, ConsoleDebuggerConfig config, ISeleniumAdapter selenium)
 {
     Data     = data;
     Config   = config;
     Selenium = selenium;
     Command  = new ConsoleDebuggerCommand(-1);
 }
Ejemplo n.º 2
0
 public TextFieldLookupStrategy(ISeleniumAdapter seleniumAdapter, bool exactMatchOnly, int order, SearchDirection direction, string labelText)
 {
     _seleniumAdapter = seleniumAdapter;
     ExactMatchOnly   = exactMatchOnly;
     Order            = order;
     Direction        = direction;
     LabelText        = labelText;
 }
Ejemplo n.º 3
0
 public DirectLookupStrategyWithNeighbours(ISeleniumAdapter seleniumAdapter,
                                           string labelText, SearchDirection searchDirection, int order, List <ITagSelector> searchedTagNames, bool exactMatchOnly = true)
 {
     _seleniumAdapter  = seleniumAdapter;
     _labelText        = labelText;
     _searchDirection  = searchDirection;
     _order            = order;
     _exactMatchOnly   = exactMatchOnly;
     _searchedTagNames = searchedTagNames;
 }
Ejemplo n.º 4
0
        private MouseEventHandler HandleMouseMove(ISeleniumAdapter selenium)
        {
            return(delegate(object o, MouseEventArgs args)
            {
                this.HoverX = ((MouseEventArgs)args).X;
                this.HoverY = ((MouseEventArgs)args).Y;

                var windowRect = selenium.BrowserWindowScreenRectangle;
                var topLeft = new Point(windowRect.Left, windowRect.Top);
                var bottomRight = new Point(windowRect.Right, windowRect.Bottom);

                UserInteropAdapter.ScreenToGraphics(ref topLeft);
                UserInteropAdapter.ScreenToGraphics(ref bottomRight);
                float height = Math.Abs(bottomRight.Y - topLeft.Y);
                float width = Math.Abs(bottomRight.X - topLeft.X);
                var contentTopLeft = new Point(windowRect.Left, windowRect.Top);
                contentTopLeft.X += selenium.ContentOffsetX();
                contentTopLeft.Y += selenium.ContentOffsetY();
                //

                var point = new Point(this.HoverX, this.HoverY);
                selenium.ConvertFromScreenToWindow(ref point);
                selenium.ConvertFromWindowToPage(ref point);

                var elements = selenium.WebDriver.GetElementByCoordinates(point.X, point.Y);

                var element = elements.LastOrDefault(x => x.IsClickable());

                //Console.Out.Wipe();
                //Console.Out.BeginRewritableLine();
                //Console.Out.WriteColored(ConsoleColor.Yellow, $"X {HoverX:D4} Y {HoverY:D4} ");
                //Console.Out.WriteColored(ConsoleColor.Green, $"{(element == null ? "                        " : $" -- Button {element.Text} --")}");


                //Console.Out.WriteColored(ConsoleColor.Magenta, $"width {width} height {height} ");


                if (element != null)
                {
                    var p = new Point(element.Location.X, element.Location.Y);

                    selenium.ConvertFromPageToWindow(ref p);
                    selenium.ConvertFromWindowToScreen(ref p);
                    selenium.ConvertFromScreenToGraphics(ref p);

                    ElementLocation = p;
                    ElementSize = element.Size;
                }
                else
                {
                    ElementLocation = default(Point);
                }
            });
        }
Ejemplo n.º 5
0
        private void Render(Graphics backBuffer, ISeleniumAdapter selenium)
        {
            var windowRect  = selenium.BrowserWindowScreenRectangle;
            var topLeft     = new Point(windowRect.Left, windowRect.Top);
            var bottomRight = new Point(windowRect.Right, windowRect.Bottom);

            UserInteropAdapter.ScreenToGraphics(ref topLeft);
            UserInteropAdapter.ScreenToGraphics(ref bottomRight);

            backBuffer.Clear(Color.Black);

            float height = Math.Abs(bottomRight.Y - topLeft.Y);
            float width  = Math.Abs(bottomRight.X - topLeft.X);

            var contentTopLeft = new Point(windowRect.Left, windowRect.Top);

            contentTopLeft.X += selenium.ContentOffsetX();
            contentTopLeft.Y += selenium.ContentOffsetY();
            if (!ClickThrough)
            {
                backBuffer.FillRectangle(new SolidBrush(BackgroundColor), contentTopLeft.X + 8, contentTopLeft.Y, width - selenium.ContentOffsetX() - 16, height - selenium.ContentOffsetY() - 18);
            }

            backBuffer.FillRectangle(new SolidBrush(HeaderColor), topLeft.X + 8, topLeft.Y + 22, width - 16, 24);
            backBuffer.DrawRectangle(new Pen(HeaderColor, 10), topLeft.X + 8, topLeft.Y, width - 16, height - 8);

            backBuffer.DrawString(Title, new Font(FontFamily.GenericSansSerif, 14), new SolidBrush(Color.FromArgb(255, 10, 10, 10)), topLeft.X + 340, topLeft.Y + 22);

            if (ElementLocation != default(Point))
            {
                backBuffer.DrawRectangle(new Pen(Color.FromArgb(255, 0, 50, 150), 4),
                                         ElementLocation.X - 2, ElementLocation.Y - 2, ElementSize.Width + 4, ElementSize.Height + 4);
                backBuffer.FillRectangle(new SolidBrush(Color.FromArgb(255, 100, 255, 255)),
                                         ElementLocation.X - 2, ElementLocation.Y - 2, ElementSize.Width + 4, ElementSize.Height + 4);
            }

            foreach (var artifact in Artifacts)
            {
                var rectangle = new Rectangle(artifact.Rectangle.X, artifact.Rectangle.Y, artifact.Rectangle.Width, artifact.Rectangle.Height);

                _seleniumAdapter.ConvertFromPageToWindow(ref rectangle);
                _seleniumAdapter.ConvertFromWindowToScreen(ref rectangle);
                _seleniumAdapter.ConvertFromScreenToGraphics(ref rectangle);

                backBuffer.DrawRectangle(new Pen(artifact.LineColor, 6),
                                         rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                backBuffer.FillRectangle(new SolidBrush(artifact.BackgroundColor),
                                         rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);

                backBuffer.DrawString(artifact.Text, new Font(FontFamily.GenericSansSerif, 12), new SolidBrush(Color.FromArgb(255, 10, 10, 10)), rectangle.X, rectangle.Y);
            }
        }
Ejemplo n.º 6
0
        public static void HighlightPoints(int wait, ISeleniumAdapter selenium, params Point[] points)
        {
            using (var overlay = new Overlay())
            {
                var handle = selenium.BrowserHandle;
                overlay.Init();


                for (int index = 0; index < points.Length; index++)
                {
                    var point = points[index];
                    overlay.DrawStuff(handle, index, point.X - 15, point.Y - 15, overlay.Graphics, 30, 30, Color.FromArgb(255, 0, 255, 255), Color.FromArgb(255, 255, 0, 255));
                }

                Thread.Sleep(wait);
            }
        }
Ejemplo n.º 7
0
 public DirectLookupStrategy(ISeleniumAdapter seleniumAdapter,
                             List <ITagSelector> searchedTagNames,
                             string subjectName,
                             string locale,
                             SearchDirection searchDirection,
                             int order,
                             bool orthogonalOnly,
                             bool exactMatchOnly = true)
 {
     _seleniumAdapter  = seleniumAdapter;
     _searchedTagNames = searchedTagNames;
     _subjectName      = subjectName;
     _locale           = locale;
     _searchDirection  = searchDirection;
     _order            = order;
     _orthogonalOnly   = orthogonalOnly;
     _exactMatchOnly   = exactMatchOnly;
 }
Ejemplo n.º 8
0
        public static void HighlightElements(Action action, ISeleniumAdapter seleniumAdapter, IEnumerable <IBufferedElement> elements, Color innerColor, Color outerColor, int selectionIndex, Color selectionColor, int xOffset = 0, int yOffset = 0)
        {
            using (var overlay = new Overlay())
            {
                if (selectionIndex != -1 && elements.Count() > selectionIndex)
                {
                    seleniumAdapter.PutElementOnScreen(elements.ElementAt(selectionIndex).WebElement);
                }
                var handle = seleniumAdapter.BrowserHandle;
                overlay.Init();
                int i = 0;
                foreach (var element in elements)
                {
                    i++;

                    var p = new Point(element.Rectangle.Left, element.Rectangle.Top);
                    seleniumAdapter.ConvertFromPageToWindow(ref p);

                    overlay.DrawStuff(handle, i, p.X, p.Y,
                                      overlay.Graphics, element.Rectangle.Width, element.Rectangle.Height,
                                      i == (1 + selectionIndex) ? selectionColor : innerColor,
                                      outerColor);

                    if (xOffset != 0 || yOffset != 0)
                    {
                        overlay.Graphics.DrawLine(Pens.Red,
                                                  p.X + element.Rectangle.Width / 2,
                                                  p.Y + element.Rectangle.Height / 2,
                                                  p.X + element.Rectangle.Width / 2 + xOffset,
                                                  p.Y + element.Rectangle.Height / 2 + yOffset);
                    }
                }

                Console.Out.WriteColoredLine(ConsoleColor.White,
                                             $"{elements.Count()} elements highlighted on screen. Press enter to continue (highlighting will disappear).");


                action.Invoke();
            }
        }
Ejemplo n.º 9
0
 public static void HighlightElements(ISeleniumAdapter seleniumAdapter, IEnumerable <IBufferedElement> elements, Color innerColor, Color outerColor, int selectionIndex, Color selectionColor)
 {
     HighlightElements(() => Console.ReadLine(), seleniumAdapter, elements, innerColor, outerColor, selectionIndex, selectionColor);
 }
Ejemplo n.º 10
0
 public AnnotationOverlay(ISeleniumAdapter seleniumAdapter)
 {
     _seleniumAdapter = seleniumAdapter;
 }
Ejemplo n.º 11
0
 public FluentElementQuery(ISeleniumAdapter seleniumAdapter)
 {
     _seleniumAdapter = seleniumAdapter;
 }
Ejemplo n.º 12
0
 private FluentElementQuery(ISeleniumAdapter seleniumAdapter, ReadOnlyCollection <IWebElement> query)
 {
     _seleniumAdapter = seleniumAdapter;
     _query           = new ReadOnlyCollection <IWebElement>(new List <IWebElement>(query));
 }
 private LocationHeuristictSearchStrategy(ISeleniumAdapter seleniumAdapter, ReadOnlyCollection <IWebElement> query)
 {
     _seleniumAdapter = seleniumAdapter;
     _query           = new ReadOnlyCollection <IWebElement>(new List <IWebElement>(query));
 }
 public LocationHeuristictSearchStrategy(ISeleniumAdapter seleniumAdapter)
 {
     _seleniumAdapter = seleniumAdapter;
 }
Ejemplo n.º 15
0
 public static void HighlightElements(int wait, ISeleniumAdapter seleniumAdapter, IEnumerable <IBufferedElement> elements, Color innerColor, Color outerColor, int selectionIndex, Color selectionColor)
 {
     HighlightElements(() => Thread.Sleep(wait), seleniumAdapter, elements, innerColor, outerColor, selectionIndex, selectionColor);
 }
Ejemplo n.º 16
0
 public static void HighlightElements(ISeleniumAdapter seleniumAdapter, params IBufferedElement[] elements)
 {
     HighlightElements(seleniumAdapter, elements.ToList());
 }
Ejemplo n.º 17
0
 public static void HighlightElements(ISeleniumAdapter seleniumAdapter, IEnumerable <IBufferedElement> elements, int selectionIndex)
 {
     HighlightElements(seleniumAdapter, elements, Color.FromArgb(255, 0, 255, 255), Color.FromArgb(255, 255, 0, 255), selectionIndex, Color.FromArgb(255, 0, 255, 0));
 }