public void AreEqual(object expected, object actual, string step) { TE.BeginTestCaseStep($"Assert: {step}"); try { Assert.AreEqual(expected, actual, step); } catch (AssertionException) { TE.FailCurrentStep(expected.ToString(), actual.ToString()); throw; } }
public void AssertURLIsWhereExpected(string url, string description) { executioner.BeginTestCaseStep(description); if (!executioner.AmOnScreen(url)) { executioner.FailCurrentStep(description, "Current url does not contain " + url); Assert.IsTrue(false, description); } }
//general method to handle actions //general method to handle action on existing elements //helper method to complete the work/actions //ensure good assertions //https://stackoverflow.com/questions/2082615/pass-method-as-parameter-using-c-sharp public ElementResult ExecuteAction(ElementObject ele, ElementResult starter = null) { if (TE.TestTimeLimit < DateTime.Now) { TE.Assert.Fail($"Test Exceeded Max Time Limit of: {TE.TestTimeLimit.Subtract(TE.StartTime)} (hh:mm:ss)"); } var eleName = starter == null ? ele.ElementName : starter.ElementName; if (ele.ReportStep) { switch (ele.Action) { case ElementAction.Click: case ElementAction.EnterText: case ElementAction.Dropdown: case ElementAction.DropdownIndex: case ElementAction.RadioBtn: case ElementAction.MultiDropdown: case ElementAction.Hover: TE.BeginTestCaseStep($"Execute action {ele.Action} on element: {eleName}", ele.Random || ele.ProtectedValue ? "Random Value" : ele.Text); break; } } var element = starter; //check if 'ele' has an element in it or not. if (!string.IsNullOrEmpty(ele.EleRef)) { if (ele.EleType == ElementType.AccessabilityId) { element = FindAppiumElement(ele, starter?.RawEle); } else { var finder = ElementFinder(ele); element = FindElement(ele, finder, starter?.RawEle); } } return(CompleteAction(ele, element)); }