Example #1
0
        /// <summary>
        /// Method to find the specified pattern on the screen
        /// </summary>
        /// <param name="pattern">The pattern object passed to the tool for searching</param>
        public void Find(Pattern pattern, bool highlight = false)
        {
            json_Find   jFind   = new json_Find(pattern.ToJsonPattern(), highlight);
            String      jFindS  = JsonConvert.SerializeObject(jFind);
            json_Result jResult = json_Result.getJResult(MakeRequest("find", jFindS));

            FailIfResultNotPASS(jResult);
        }
Example #2
0
 /// <summary>
 /// Method to check the json_Result object and throw an exception if the Result is not PASSing
 /// </summary>
 /// <param name="jResult">the json_Result to check</param>
 public void FailIfResultNotPASS(json_Result jResult)
 {
     Util.Log.WriteLine("Result: " + jResult.result + " Message: " + jResult.message + " Stacktrace: " + jResult.stacktrace);
     if (!jResult.ToActionResult().Equals(ActionResult.PASS))
     {
         throw new SikuliActionException(jResult.ToActionResult(), jResult.message);
     }
 }
Example #3
0
        /// <summary>
        /// Method to click and drag from one pattern to another
        /// </summary>
        /// <param name="clickPattern">The pattern to start the drag from</param>
        /// <param name="dropPattern">The pattern to drop at</param>
        public void DragDrop(Pattern clickPattern, Pattern dropPattern)
        {
            json_DragDrop jDragDrop  = new json_DragDrop(clickPattern.ToJsonPattern(), dropPattern.ToJsonPattern());
            String        jDragDropS = JsonConvert.SerializeObject(jDragDrop);
            json_Result   jResult    = json_Result.getJResult(MakeRequest("dragdrop", jDragDropS));

            FailIfResultNotPASS(jResult);
        }
Example #4
0
        /// <summary>
        /// Method to type the specified text into the specified pattern after locating it on the screen
        /// </summary>
        /// <param name="pattern">The pattern object passed to the tool for typing</param>
        /// <param name="text">The text to type in the pattern, if it is found</param>
        /// <param name="kmod">Any key modifiers to press while typing.  example: Control, Shift, Enter, etc...</param>
        public void Type(Pattern pattern, String text, KeyModifier kmod = KeyModifier.NONE)
        {
            json_Type   jType   = new json_Type(pattern.ToJsonPattern(), text, kmod);
            String      jTypeS  = JsonConvert.SerializeObject(jType);
            json_Result jResult = json_Result.getJResult(MakeRequest("type", jTypeS));

            FailIfResultNotPASS(jResult);
        }
Example #5
0
        /// <summary>
        /// Method to wait for a specific Pattern to appear on the screen.  If it does not appear by the specified timeout (in seconds), the action fails.
        /// </summary>
        /// <param name="pattern">The pattern object passed to the tool for waiting</param>
        /// <param name="timeout">The timeout, in seconds, before the action fails</param>
        public void Wait(Pattern pattern, Double timeout = 15)
        {
            json_Wait   jWait   = new json_Wait(pattern.ToJsonPattern(), timeout);
            String      jWaitS  = JsonConvert.SerializeObject(jWait);
            json_Result jResult = json_Result.getJResult(MakeRequest("wait", jWaitS));

            FailIfResultNotPASS(jResult);
        }
Example #6
0
        /// <summary>
        /// Method to double click on the specified pattern
        /// </summary>
        /// <param name="pattern">The pattern object passed to the tool for clicking</param>
        public void DoubleClick(Pattern pattern, KeyModifier kmod = KeyModifier.NONE, bool highlight = false)
        {
            if (highlight)
            {
                Find(pattern, highlight);
            }
            json_Click  jClick  = new json_Click(pattern.ToJsonPattern(), kmod);
            String      jClickS = JsonConvert.SerializeObject(jClick);
            json_Result jResult = json_Result.getJResult(MakeRequest("doubleclick", jClickS));

            FailIfResultNotPASS(jResult);
        }