public void RandomNoSuchElement() => Execute(attempts: 5, test: () => { // setup var iterations = 0; // iterate while (iterations < 1) { try { MockWebElement.GetElement(new MockWebDriver(), MockBy.RandomNoSuchElement()); } catch (Exception e) when(e is NoSuchElementException) { iterations++; } } // assertion Assert.IsTrue(iterations > 0); });