Example #1
0
        /// <summary>
        /// method to apply when a non-terminal node has been found
        /// </summary>
        /// <param name="ah"></param>
        public void visitNode(AccessibilityHelper ah)
        {         // does this ah need to be clicked or something to get to its children?
            if (1 == m_logLevel)
            {
                m_log.paragraph(makeNameTag() + "Click found &quot;" + ah.Role + ":" + ah.Name + "&quot;");
            }

            if ((ah.Role == AccessibleRole.MenuItem) || (m_for != null && "all" == (string)m_for))
            {
                if (1 == m_logLevel)
                {
                    m_log.paragraph(makeNameTag() + "Click determining what to do with this intermediate step");
                }
                bool isFocused = (ah.States & AccessibleStates.Focused) == AccessibleStates.Focused;
                if (!isFocused)
                {
                    if (1 == m_logLevel)
                    {
                        m_log.paragraph(makeNameTag() + "Clicking relative to &quot;" + ah.Role + ":" + ah.Name + "&quot; by (" + m_dx + ", " + m_dy + ") since it does not have focus");
                    }
                    ah.SimulateClickRelative(m_dx, m_dy);
                }
                else
                {
                    if (1 == m_logLevel)
                    {
                        m_log.paragraph(makeNameTag() + "Click hovering on &quot;" + ah.Role + ":" + ah.Name + "&quot; since it has focus");
                    }
                    ah.MoveMouseOverMe();                     // hover
                }
            }
        }
Example #2
0
        /// <summary>
        /// Click on an appPath via the gui model and/or a guiPath via
        /// Active Accessibility.
        /// If only the context is not null, it's value is used.
        /// If the context is null, the model root is used with appPath.
        /// The appPath is applied first, if any, then the guiPath.
        /// If there is no context or appPath, the guiPath is used.
        /// </summary>
        /// <param name="context">Model node to start appPath from or null</param>
        /// <param name="appPath">the appPath to a control or null</param>
        /// <param name="guiPath">the guiPath to click or null</param>
        /// <param name="leftClick">true if left-click, false on right-click</param>
        /// <returns>true if the path was valid and a click attempted</returns>
        private bool click(XmlNode context, string appPath, string guiPath, bool leftClick)
        {
            // if only a context, select it to click on.
            XmlPath xp = m_GuiModel.selectToXmlPath(context, appPath);

            if (xp == null || !xp.isValid())
            {
                return(false);
            }
            AccessibilityHelper ah = findInGui(xp, guiPath);

            if (ah == null)
            {
                return(false);
            }
            if (leftClick)
            {
                ah.SimulateClickRelative(10, 10);
            }
            else
            {
                ah.SimulateRightClickRelative(10, 10);
            }
            return(true);
        }
Example #3
0
 /// <summary>
 /// method to apply when a non-terminal node has been found
 /// </summary>
 /// <param name="ah"></param>
 public void visitNode(AccessibilityHelper ah)
 {         // does this ah need to be clicked or something to get to its children?
     if (ah.Role == AccessibleRole.MenuItem)
     {
         bool isFocused = (ah.States & AccessibleStates.Focused) == AccessibleStates.Focused;
         if (!isFocused)
         {
             ah.SimulateClickRelative(10, 10);
         }
         else
         {
             ah.MoveMouseOverMe();                             // hover
         }
     }
 }
Example #4
0
 private string ClickPath(AccessibilityHelper ah, GuiPath gpath)
 {
     //bool forAll = false;
     //bool clickParent = false;
     //AccessibilityHelper child;
     //if (m_for != null && "all" == (string)m_for) forAll = true;
     if (1 == m_logLevel)
     {
         m_log.paragraph(makeNameTag() + "Click starting path from &quot;" + ah.Role + ":" + ah.Name + "&quot;");
     }
     ah = gpath.FindInGui(ah, this);
     if (ah != null)
     {
         if (1 == m_logLevel)
         {
             m_log.paragraph(makeNameTag() + "Clicking last pair in path");
         }
         int j;
         for (j = 0; j < m_repeat; j++)
         {                  // click 10 pixels from the left edge - see below
             if (m_side == "right")
             {
                 ah.SimulateRightClickRelative(m_dx, m_dy);
             }
             else
             {
                 ah.SimulateClickRelative(m_dx, m_dy);
             }
             // when @wait="no" don't wait at all between repeated clicks
             if (m_wait)
             {
                 Thread.Sleep(400);                             // wait a while eg. let menus open, etc.
             }
         }
         m_finished = true;                 // tell do-once it's done
     }
     else
     {
         return(m_message);
     }
     return("");
 }
Example #5
0
        /// <summary>
        /// Checks for an open error window and closes it.
        /// This may close the application.
        /// Also, set doAssert to true if this test should terminate on finding one.
        /// </summary>
        /// <param name="doAssert">false when the test should not fail as when another test caused the error window.</param>
        protected void CheckForErrorDialogs(bool doAssert)
        {           // check for specific error dialogs
            // Try to get the ah for "An error has occurred" window
            // Log its info
            // Close the error window
            // Assert if directed to
            AccessibilityHelper ah = new AccessibilityHelper("An error has occurred");
            // This constructor returns the top window if it can't find the
            // one with the title
            // Even though the ah is not null, sometimes it can't get the name
            string name = "";

            if (ah != null && ah.Name == "An error has occurred")
            {             // this is really bad!
                string color = "green";
                m_log = Logger.getOnly();
                m_log.paragraph("Window: " + name);
                GuiPath             path   = new GuiPath("button:Exit the application");
                AccessibilityHelper ahExit = ah.SearchPath(path, null);
                if (ahExit == null)
                {
                    color  = "yellow";                    // can continue
                    path   = new GuiPath("button:Ok");
                    ahExit = ah.SearchPath(path, null);
                }
                if (ahExit == null)
                {
                    color = "unknown";
                }
                if (color == "green")
                {
                    m_log.paragraph("Found a green error window!");
                }
                if (color == "yellow")
                {
                    m_log.paragraph("Found a yellow error window! Continuing...");
                }
                if (color == "unknown")
                {
                    m_log.paragraph("Found an unknown error window!");
                }
                // write the error text to the log
                path = new GuiPath("window:NAMELESS[2]");
                AccessibilityHelper ahTextWin = ah.SearchPath(path, null);
                AccessibilityHelper ahText    = null;
                if (ahTextWin != null)
                {
                    path   = new GuiPath("text:NAMELESS[2]");
                    ahText = ah.SearchPath(path, null);
                }
                if (ahText != null)
                {
                    m_log.paragraph(ahText.Value);
                }
                else
                {
                    m_log.paragraph(@"Don't know where to get the message text from.");
                }
                if (color == "green" || color == "yellow")
                {
                    ahExit.SimulateClickRelative(10, 10);
                }
                if (doAssert && color == "green")
                {
                    fail("Got an error window!");
                }
                if (color == "unknown")
                {
                    Application.SendKeys(@"{ESC}");                     // exits error window but maybe not the app
                }
                if (doAssert && color == "unknown")
                {
                    fail("Closed the unknown error window.");
                }
                Thread.Sleep(20000);                 // if still alive, wait for things to calm down
            }
        }