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

Bug reports.
Voland
Posts: 7
Joined: Wed Jul 05, 2017 1:29 pm

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

Post by Voland » Wed Jul 05, 2017 1:45 pm

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 @[email protected]@[email protected]";
			}
			text = Validate.ExistsInternal(path, searchTimeout);
			message = message.Replace("@[email protected]", 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?

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

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

Post by tvu » Wed Jul 05, 2017 9:28 pm

You can use the WaitForNotExists() method.

Voland
Posts: 7
Joined: Wed Jul 05, 2017 1:29 pm

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

Post by Voland » Mon Jul 10, 2017 9:13 am

tvu wrote:You can use the WaitForNotExists() method.
Thanks :) that seems to do the job.