public void CheckRadioButton() { NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite()); LinkHelper.ClickLink(By.LinkText("File a Bug")); Thread.Sleep(100); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername()); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword()); ButtonHelper.ClickOnButton(By.Id("log_in")); Thread.Sleep(100); LinkHelper.ClickLink(By.XPath("//div[@id='header']/ul[1]/li[9]/a")); LinkHelper.ClickLink(By.LinkText("Parameters")); Thread.Sleep(100); Console.WriteLine("Radio button status: {0}", RadioButtonHelper.IsRadioButtonChecked(By.Id("ssl_redirect-on"))); RadioButtonHelper.CheckedRadioButton(By.Id("ssl_redirect-on")); Console.WriteLine("Radio button status: {0}", RadioButtonHelper.IsRadioButtonChecked(By.Id("ssl_redirect-on"))); Console.WriteLine(GenericHelpers.GetElement(By.XPath("//div[@id='header']/ul[1]/li[11]/a")).Text); LinkHelper.ClickLink(By.XPath("//div[@id='header']/ul[1]/li[11]/a")); }
public void CheckDropDownList() { NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite()); LinkHelper.ClickLink(By.LinkText("File a Bug")); Thread.Sleep(100); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername()); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword()); ButtonHelper.ClickOnButton(By.Id("log_in")); DropdownListHelper.SelectElement(By.Id("bug_severity"), 2); DropdownListHelper.SelectElement(By.Id("bug_severity"), "minor"); IList <string> getAllOptions = DropdownListHelper.GetAllItems(By.Id("bug_severity")); foreach (string var in getAllOptions) { Console.WriteLine(var); } }
public void PerformActions(string keyword, string locatorType, string locatorValue, params string[] parameters) { switch (keyword) { case "Click": ButtonHelper.ClickOnButton(GetElementLocator(locatorType, locatorValue)); break; case "SendKeys": { TextBoxHelper.ClearTextbox(GetElementLocator(locatorType, locatorValue)); TextBoxHelper.TypeInTextbox(GetElementLocator(locatorType, locatorValue), parameters[0]); } break; case "Navigate": NavigationHelper.NavigationToURL(parameters[0]); break; case "Select": DropdownListHelper.SelectElement(GetElementLocator(locatorType, locatorValue), parameters[0]); break; case "WaitForEle": GenericHelpers.WaitForElementInPage(GetElementLocator(locatorType, locatorValue), TimeSpan.FromSeconds(60)); break; default: throw new NoSuchKeywordException("No such keyword found" + keyword); } }
public void TestDefaultWait() { NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite()); LinkHelper.ClickLink(By.LinkText("File a Bug")); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername()); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword()); ButtonHelper.ClickOnButton(By.Id("log_in")); ObjectRepository.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); GenericHelpers.WaitForElement(By.Id("bug_severity"), TimeSpan.FromSeconds(50)); IWebElement ele = GenericHelpers.WaitForElementInPage(By.Id("bug_severity"), TimeSpan.FromSeconds(50)); SelectElement select = new SelectElement(ele); select.SelectByText("major"); //DefaultWait<IWebElement> wait = new DefaultWait<IWebElement>(ObjectRepository.Driver.FindElement(By.Id("bug_severity"))); //wait.PollingInterval = TimeSpan.FromMilliseconds(200); //wait.Timeout = TimeSpan.FromSeconds(50); //wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException)); //Console.WriteLine($"After wait: {wait.Until(WaitForValueChange())}"); }
public void Textbox() { NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite()); LinkHelper.ClickLink(By.LinkText("File a Bug")); Thread.Sleep(100); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername()); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword()); }
public void FillInTextbox(string summary = null, string description = null) { if (summary != null) { TextBoxHelper.ClearTextbox(summaryTextbox); TextBoxHelper.TypeInTextbox(summaryTextbox, summary); } if (description != null) { TextBoxHelper.ClearTextbox(descriptionTextbox); TextBoxHelper.TypeInTextbox(descriptionTextbox, description); } }
public void Checkbox() { NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite()); LinkHelper.ClickLink(By.LinkText("File a Bug")); Thread.Sleep(100); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername()); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword()); Console.WriteLine(CheckboxHelper.IsChecboxChecked(By.Id("Bugzilla_restrictlogin"))); if (CheckboxHelper.IsChecboxChecked(By.Id("Bugzilla_restrictlogin"))) { CheckboxHelper.CheckedCheckbox(By.Id("Bugzilla_restrictlogin")); } Console.WriteLine(CheckboxHelper.IsChecboxChecked(By.Id("Bugzilla_restrictlogin"))); }
public void MultiElements() { NavigationHelper.NavigationToURL(ObjectRepository.Config.GetWebsite()); LinkHelper.ClickLink(By.LinkText("File a Bug")); Thread.Sleep(100); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_login")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_login"), ObjectRepository.Config.GetUsername()); TextBoxHelper.ClearTextbox(By.Id("Bugzilla_password")); TextBoxHelper.TypeInTextbox(By.Id("Bugzilla_password"), ObjectRepository.Config.GetPassword()); ButtonHelper.ClickOnButton(By.Id("log_in")); Thread.Sleep(100); ReadOnlyCollection <IWebElement> elements = ObjectRepository.Driver.FindElements(By.LinkText("Administration")); Console.WriteLine(elements[0].Text.ToString()); Console.WriteLine(elements[1].Text.ToString()); }
public void TestAlert() { //NavigationHelper.NavigationToURL("https://www.w3schools.com/js/js_popup.asp"); //ButtonHelper.ClickOnButton(By.XPath("//div[@id='main']/descendant::a[position()=3]")); //BrowserHelper.SwitchToWindow(1); //switch to iframe to work on Iframe NavigationHelper.NavigationToURL("https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert"); ObjectRepository.Driver.SwitchTo().Frame(ObjectRepository.Driver.FindElement(By.Id("iframeResult"))); ButtonHelper.ClickOnButton(By.XPath("//button[text()='Try it']")); if (JavaScriptPopupHelper.IsPopupPresent()) { var text = JavaScriptPopupHelper.GetPopupText(); JavaScriptPopupHelper.ClickOKonPopup(); ObjectRepository.Driver.SwitchTo().DefaultContent(); // Add this line before the line of code , where you are trying to clear the text area IWebElement textarea = ObjectRepository.Driver.FindElement(By.Id("textareaCode")); ExecuteScript("document.getElementById('textareaCode').setAttribute('style','display: inline;')"); TextBoxHelper.ClearTextbox(By.Id("textareaCode")); TextBoxHelper.TypeInTextbox(By.Id("textareaCode"), text); } }