Exemple #1
0
        public static void takeScreenShot(TestStack.White.UIItems.UIItem b)
        {
            try
            {
                String path;
                Rect   bounds = b.Bounds;

                //getting values from Rect
                double h = bounds.Height;
                double w = bounds.Width;
                double x = bounds.X;
                double y = bounds.Y;
                //gettomg ramdom number, can change it to date time or somehting meaningful
                Random rndm = new Random();
                //this will generate randomnumber between 1 to 10,000
                int random = rndm.Next(10000);

                //getting current directory
                path = System.AppDomain.CurrentDomain.BaseDirectory;
                //replaceing the bin and debug as BaseDirectory will return this
                path = path.Replace("\\bin\\Debug", "");
                //creating path with random integer
                path = path + "results\\Screenshot_" + random + ".jpg";

                //logic for creating
                //creating equalent in System.Drawing
                //Source point
                System.Drawing.Point p = new System.Drawing.Point(Convert.ToInt32(x), Convert.ToInt32(y));
                //Destination point
                System.Drawing.Point p2 = new System.Drawing.Point(0, 0);

                //Creating Rectangle from Rect
                System.Drawing.Rectangle rect = new Rectangle(p.X, p.Y, Convert.ToInt32(w), Convert.ToInt32(h));

                //Creating bitmap with desired height and width
                Bitmap bitmap = new Bitmap(rect.Width, rect.Height);

                {
                    Graphics g = Graphics.FromImage(bitmap);
                    {
                        //Coping screen where automation element is present (p) to destnation point on the image (0,0)
                        g.CopyFromScreen(p, p2, rect.Size);
                    }
                    //Saving image
                    bitmap.Save(path, ImageFormat.Jpeg);
                }
            }
            catch (Exception e)

            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #2
0
        public virtual void ClickOutsideToolTip(UIItem uiItem, IActionListener actionListener)
        {
            actionListener.ActionPerforming(uiItem);
            ToolTip toolTip = GetToolTip(uiItem, actionListener);

            if (toolTip == null)
            {
                mouse.LeftClick(uiItem.Bounds.Center(), actionListener);
            }
            else
            {
                logger.Debug("Found tooltip Clicking outside tooltip bounds");
                mouse.LeftClick(toolTip.LeftOutside(uiItem.Bounds), actionListener);
            }
        }
Exemple #3
0
        public virtual void RightClickOutsideToolTip(UIItem uiItem, IActionListener actionListener)
        {
            actionListener.ActionPerforming(uiItem);
            ToolTip toolTip = GetToolTip(uiItem, actionListener);

            if (toolTip == null)
            {
                //Because mouse has already been moved
                mouse.Click(MouseButton.Right, actionListener);
            }
            else
            {
                logger.Debug("Found tooltip RightClicking outside tooltip bounds");
                mouse.RightClick(toolTip.LeftOutside(uiItem.Bounds), actionListener);
            }
        }
Exemple #4
0
 /// <summary>
 /// Implements <see cref="IActionListener.ActionPerforming"/>
 /// </summary>
 public virtual void ActionPerforming(UIItem uiItem)
 {
 }
        //**************************************************************************************************************************************************************

        public static void UIA_ClickItemByAutomationID(AutomationElement uiaWindow, Window window, string automationID)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);

            try
            {
                AutomationProperty p = AutomationElementIdentifiers.AutomationIdProperty;
                PropertyCondition condition = new PropertyCondition(p, automationID);
                AutomationElement element = uiaWindow.FindFirst(TreeScope.Descendants, condition);

                TestStack.White.UIItems.UIItem e = new TestStack.White.UIItems.UIItem(element, window.ActionListener);
                e.Focus();
                e.Click();
                Thread.Sleep(int.Parse(Execution_Speed));
                Logger.logMessage("UIA_ClickItemByAutomationID " + uiaWindow + "->" + window + "->" + automationID + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
            }
            catch (Exception e)
            {
                Logger.logMessage("UIA_ClickItemByAutomationID " + uiaWindow + "->" + window + "->" + automationID + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
Exemple #6
0
 public ToggleableItem(UIItem uiItem) : base(uiItem.AutomationElement, uiItem.ActionListener)
 {
 }
Exemple #7
0
 public override void ActionPerforming(UIItem uiItem)
 {
     new ScreenItem(uiItem, ScrollBars).MakeVisible(this);
 }
Exemple #8
0
        /// <summary>
        /// Find all the UIItems which belongs to a window and are within (bounds of) another UIItem.
        /// </summary>
        /// <param name="containingItem">Containing item</param>
        /// <returns>List of all the items.</returns>
        public virtual List <UIItem> ItemsWithin(UIItem containingItem)
        {
            UIItemCollection itemsWithin = factory.ItemsWithin(containingItem.Bounds, this);

            return(itemsWithin.Where(item => !item.Equals(containingItem)).Cast <UIItem>().ToList());
        }
Exemple #9
0
 public virtual ToolTip GetToolTipOn(UIItem uiItem)
 {
     Mouse.Location = uiItem.Bounds.Center();
     uiItem.Focus();
     return(ToolTip);
 }