Page 1 of 1

Validate.NotExists() does not wait for element to not exist

Posted: Wed Jul 05, 2017 1:45 pm
by Voland
Hi,
I am currently using NotExists() method in my test and It does not wait for element to change state.

Element that I am testing waits for Push notification and is removed from list afterwards.
This push notification arrives in random period of time so I have to wait for it 1-7sec.

I checked NotExists() method implementation

Code: Select all

public static bool NotExists(string path, Duration searchTimeout, string message, Validate.Options options)
		{
			string text;
			if (!(!string.op_Equality(message, Validate.DefaultMessage)))
			{
				message = "Element for path '{0}' does @ValidateTRUENOT@[email protected]@.";
			}
			text = Validate.ExistsInternal(path, searchTimeout);
			message = message.Replace("@Validate.ExistsREASON@", text);
			message = string.Format(message, path ?? Validate.NullString);
			return Validate.IsTrueInternal(!string.IsNullOrEmpty(text), message, options, null);
		}
Duration searchTimeout is passed in parameters to ExistsInternal() method

Code: Select all

internal static string ExistsInternal(string path, Duration searchTimeout)
		{
			string result;
			RanorexException ex;
			result = string.Empty;
			try
			{
				result = Validate.ExistsInternal(new RxPath(path), searchTimeout);
			}
			catch (ArgumentNullException)
			{
				result = " (path is null)";
			}
			catch (RanorexException ex)
			{
				result = string.Concat(" (", Validate.EscapeForFormat(ExceptionHelper.GetExceptionFullMessage(ex)), ")");
			}
			return result;
		}
Yet SearchTimeout is not used anywhere in it.

Is there any other method I could use for my purpose?

Re: Validate.NotExists() does not wait for element to not exist

Posted: Wed Jul 05, 2017 9:28 pm
by tvu
You can use the WaitForNotExists() method.

Re: Validate.NotExists() does not wait for element to not exist

Posted: Mon Jul 10, 2017 9:13 am
by Voland
tvu wrote:You can use the WaitForNotExists() method.
Thanks :) that seems to do the job.