Example #1
0
 /// <summary>cehcsk if a ui element is null</summary>
 /// <param name="hook">element</param>
 /// <returns>true if the element is null</returns>
 public bool CheckIfNull(iOSHook hook)
 {
     CommandResult cr = IssueiOSAutomationCommand(hook.ToString() + " == null || " + hook.ToString() +".toString() == \"[object UIAElementNil]\"")[0];
     if (cr.WasSuccessful)
         return cr.CommandOutput.ToLower().StartsWith("true");
     else
         throw new Exception(cr.CommandOutput);
 }
Example #2
0
 /// <summary>gets the name of the supplied element</summary>
 /// <param name="hook">element</param>
 /// <returns>name of the element</returns>
 public string GetName(iOSHook hook)
 {
     CommandResult cr = IssueiOSAutomationCommand(hook.ToString() + ".name();")[0];
     return (cr.WasSuccessful) ? cr.CommandOutput : null;
 }
Example #3
0
 /// <summary>gets the hook</summary>
 /// <param name="hook">the ios hook to get</param>
 /// <returns>the javascript object associated with the hook (as a string)</returns>
 public string Get(iOSHook hook)
 {
     return IssueiOSAutomationCommand(hook.ToString() + ";")[0].CommandOutput;
 }
Example #4
0
 /// <summary>waits for an element to be non-null</summary>
 /// <param name="hook">element</param>
 /// <param name="maxTimeInMilliseconds">maximum amount of time to wait in millisecond</param>
 /// <returns>true if the element is not null in the supplied timeframe</returns>
 public bool WaitForNotNull(iOSHook hook, int maxTimeInMilliseconds=30000)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("var result = false; var startTime = new Date().getTime(); while(new Date().getTime() - startTime < ");
     sb.Append(maxTimeInMilliseconds.ToString());
     sb.Append(") { try { var e = ");
     sb.Append(hook.ToString());
     sb.Append("; if (e != null && e.toString() != \"[object UIAElementNil]\") { result = true; startTime = 0; } } catch(e) { } } result;");
     CommandResult cr = IssueiOSAutomationCommand(sb.ToString())[0];
     if (cr.WasSuccessful)
         return cr.CommandOutput.ToLower().StartsWith("true");
     else
         throw new Exception(cr.CommandOutput);
 }
Example #5
0
 /// <summary>taps an element</summary>
 /// <param name="hook">element to tap</param>
 /// <returns>true if successful</returns>
 public bool Tap(iOSHook hook)
 {
     return IssueiOSAutomationCommand(hook.ToString() + ".tap();")[0].WasSuccessful;
 }
Example #6
0
 /// <summary>sets the value of an element</summary>
 /// <param name="hook">element whose value will be set</param>
 /// <param name="newValue">new value</param>
 /// <returns>true if successful</returns>
 public bool SetValue(iOSHook hook, string newValue)
 {
     string escapedText = newValue.Replace("\"", "\\\"");
     return IssueiOSAutomationCommand(hook.ToString() + ".setValue(\"" + escapedText + "\");")[0].WasSuccessful;
 }
Example #7
0
 /// <summary>scroll to an element</summary>
 /// <param name="hook">element to scroll to</param>
 /// <returns>true if successful</returns>
 public bool ScrollTo(iOSHook hook)
 {
     return IssueiOSAutomationCommand(hook.ToString() + ".scrollToVisible();")[0].WasSuccessful;
 }