///<summary> /// This method check/unchecks the check box /// <example>SelectCheckbox(browser, xPath, On/Off)</example> public void SelectCheckbox(ISelenium browserObj, string strLocator, string value) { try { Assert.IsTrue(browserObj.IsVisible(strLocator), strLocator + " element is not present"); if (value.ToLower().Trim() == "on") { if (!browserObj.IsChecked(strLocator)) { browserObj.Check(strLocator); CFframeworkCommonObj.PageSync(browserObj); if (!(browserObj.IsChecked(strLocator))) { Console.WriteLine("Failed to check the checkbox - " + strLocator); Fail("Failed to check the checkbox - " + strLocator); } } } else { browserObj.Uncheck(strLocator); CFframeworkCommonObj.PageSync(browserObj); if (browserObj.IsChecked(strLocator)) { Console.WriteLine("Failed to Uncheck the checkbox - " + strLocator); Fail("Failed to check the Uncheckbox - " + strLocator); } } } catch (Exception ex) { Console.WriteLine("Function 'SelectCheckbox' - Failed"); Console.WriteLine(ex.Message); Fail(ex.Message); } }
/// <summary> /// Unchecks the specified locator. /// </summary> /// <param name="locator">The locator.</param> /// <param name="type">Type of locator</param> public void Uncheck(string locator, FindType type = FindType.ById) { _selenium.Uncheck(locator); }