public void TestEnterOrCheckUnicode() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/assert.html"); Assert.AreEqual("空気", driver.FindElement(By.Id("unicode_test")).Text); driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); driver.FindElement(By.Id("user")).SendKeys("проворный"); }
public void TestRandomBooleanForRadio() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/radio_button.html"); String randomGender = GetRandomBoolean() ? "male" : "female"; driver.FindElement(By.XPath("//input[@type='radio' and @name='gender' and @value='" + randomGender + "']")).Click(); }
public void TestCKEditor() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/ckeditor-4.4.7/samples/uicolor.html"); System.Threading.Thread.Sleep(500); IWebElement ckeditorFrame = driver.FindElement(By.ClassName("cke_wysiwyg_frame")); driver.SwitchTo().Frame(ckeditorFrame); IWebElement editorBody = driver.FindElement(By.TagName("body")); editorBody.SendKeys("Selenium Recipes\n by Zhimin Zhan"); System.Threading.Thread.Sleep(500); editorBody.SendKeys("New content"); System.Threading.Thread.Sleep(500); editorBody.Clear(); // Clear content Another Method Using ActionBuilder to clear() Actions builder = new Actions(driver); builder.Click(editorBody) .KeyDown(Keys.Control) .SendKeys("a") .KeyUp(Keys.Control) .Perform(); builder.SendKeys(Keys.Backspace) .Perform(); // switch out then can drive controls on the main page driver.SwitchTo().DefaultContent(); driver.FindElement(By.ClassName("cke_button__numberedlist")).Click(); // numbered list }
public void TestRetrieveCommonLinkDetails() { Assert.AreEqual(TestHelper.SiteUrl() + "/index.html", driver.FindElement(By.LinkText("Recommend Selenium")).GetAttribute("href")); Assert.AreEqual("recommend_selenium_link", driver.FindElement(By.LinkText("Recommend Selenium")).GetAttribute("id")); Assert.AreEqual("Recommend Selenium", driver.FindElement(By.Id("recommend_selenium_link")).Text); Assert.AreEqual("a", driver.FindElement(By.Id("recommend_selenium_link")).TagName); }
public void TestTinyMCE() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/tinymce-4.1.9/tinyice_demo.html"); IWebElement tinymceFrame = driver.FindElement(By.Id("mce_0_ifr")); driver.SwitchTo().Frame(tinymceFrame); IWebElement editorBody = driver.FindElement(By.CssSelector("body")); ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].innerHTML = '<h1>Heading</h1>AgileWay'", editorBody); System.Threading.Thread.Sleep(500); editorBody.SendKeys("New content"); System.Threading.Thread.Sleep(500); editorBody.Clear(); // click TinyMCE editor's 'Numbered List' button ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].innerHTML = '<p>one</p><p>two</p>'", editorBody); // switch out then can drive controls on the main page driver.SwitchTo().DefaultContent(); IWebElement tinymceNumberListBtn = driver.FindElement(By.CssSelector(".mce-btn[aria-label='Numbered list'] button")); tinymceNumberListBtn.Click(); // Insert using JavaScripts ((IJavaScriptExecutor)driver).ExecuteScript("tinyMCE.activeEditor.insertContent('<p>Brisbane</p>')"); }
public void TestVerifySearchResultsOrder() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/data_grid.html"); System.Threading.Thread.Sleep(500); // wait JS to load driver.FindElement(By.Id("heading_product")).Click(); // sort asc ReadOnlyCollection <IWebElement> firstCells = driver.FindElements(By.XPath("//tbody/tr/td[1]")); List <String> productNames = new List <String>(); foreach (IWebElement elem in firstCells) { ; productNames.Add(elem.Text); } List <String> sortedProductNames = new List <String>(productNames); sortedProductNames.Sort(); Console.WriteLine(productNames); Console.WriteLine(sortedProductNames); Assert.AreEqual(productNames.ToString(), sortedProductNames.ToString()); driver.FindElement(By.Id("heading_product")).Click(); // sort desc System.Threading.Thread.Sleep(500); firstCells = driver.FindElements(By.XPath("//tbody/tr/td[1]")); productNames = new List <String>(); foreach (IWebElement elem in firstCells) { ; productNames.Add(elem.Text); } sortedProductNames = new List <String>(productNames); sortedProductNames.Sort(); sortedProductNames.Reverse(); Assert.AreEqual(productNames.ToString(), sortedProductNames.ToString()); }
public void TestTableWithRowsDynamiicalySetHidden() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/data_grid.html"); driver.Manage().Window.Size = new System.Drawing.Size(1024, 768); ReadOnlyCollection <IWebElement> rows = driver.FindElements(By.XPath("//table[@id='grid']/tbody/tr")); Assert.AreEqual(4, rows.Count); String firstProductName = driver.FindElement(By.XPath("//table[@id='grid']//tbody/tr[1]/td[1]")).Text; Assert.AreEqual("ClinicWise", firstProductName); driver.FindElement(By.XPath("//table[@id='grid']//tbody/tr[1]/td/button")).Click(); driver.FindElement(By.Id("test_products_only_flag")).Click(); System.Threading.Thread.Sleep(100); // Element is not currently visible // driver.FindElement(By.XPath("//table[@id='grid']//tbody/tr[1]/td/button")).Click(); ReadOnlyCollection <IWebElement> displayedRows = driver.FindElements(By.XPath("//table[@id='grid']//tbody/tr[not(contains(@style,'display: none'))]")); Assert.AreEqual(2, displayedRows.Count); IWebElement firstRowElem = displayedRows[0]; String newFirstProductName = firstRowElem.FindElement(By.XPath("td[1]")).Text; Assert.AreEqual("BuildWise", newFirstProductName); firstRowElem.FindElement(By.XPath("td/button")).Click(); }
public void TestChosenMultipleCallingMethods() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/chosen/index.html"); // ... land to the page with a chosen select list ClearChosen("chosen_multiple_chosen"); SelectChosenByLabel("chosen_multiple_chosen", "United States"); SelectChosenByLabel("chosen_multiple_chosen", "Australia"); }
public void TestIFrameByIndex() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/iframes.html"); driver.SwitchTo().Frame(0); driver.FindElement(By.Name("username")).SendKeys("agileway"); driver.SwitchTo().DefaultContent(); driver.SwitchTo().Frame(1); driver.FindElement(By.Id("radio_male")).Click(); }
public void TestIgnoreDynamicallyGeneratePrefix() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); IWebElement elemByName = driver.FindElement(By.Name("ctl00$m$g_dcb0d043_e7f0_4128_99c6_71c113f45dd8$ctl00$tAppName")); elemByName.SendKeys("full name"); elemByName.Clear(); System.Threading.Thread.Sleep(1000); driver.FindElement(By.XPath("//input[contains(@name, 'AppName')]")).SendKeys("I still can"); }
public void TestDynamicDate() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); String todaysDate = DateTime.Now.ToString("MM/dd/yyyy"); Console.WriteLine("todaysDate = " + todaysDate); driver.FindElement(By.Name("username")).SendKeys(todaysDate); driver.FindElement(By.Name("username")).SendKeys(Today("dd/MM/yyyy")); driver.FindElement(By.Name("username")).SendKeys(Tomorrow("AUS")); driver.FindElement(By.Name("username")).SendKeys(Yesterday("ISO")); }
public void TestSummerNote() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/summernote-0.6.3/demo.html"); System.Threading.Thread.Sleep(500); driver.FindElement(By.XPath("//div[@class='note-editor']/div[@class='note-editable']")).SendKeys("Text"); // click a format button: unordered list driver.FindElement(By.XPath("//button[@data-event='insertUnorderedList']")).Click(); // switch to code view driver.FindElement(By.XPath("//button[@data-event='codeview']")).Click(); // insert code (unformatted) driver.FindElement(By.XPath("//textarea[@class='note-codable']")).SendKeys("\n<p>HTML</p>"); }
public void TestIFrame() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/iframe.html"); driver.FindElement(By.Name("user")).SendKeys("agileway"); driver.SwitchTo().Frame("Frame1"); // name driver.FindElement(By.Name("username")).SendKeys("tester"); driver.FindElement(By.Name("password")).SendKeys("TestWise"); driver.FindElement(By.Id("loginBtn")).Click(); Assert.IsTrue(driver.PageSource.Contains("Signed in")); driver.SwitchTo().DefaultContent(); driver.FindElement(By.Id("accept_terms")).Click(); }
public void TestVerifyDataUniqueness() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/data_grid.html"); System.Threading.Thread.Sleep(500); // wait JS to load ReadOnlyCollection <IWebElement> secondCells = driver.FindElements(By.XPath("//tbody/tr/td[2]")); List <String> yearsReleased = new List <String>(); foreach (IWebElement elem in secondCells) { ; yearsReleased.Add(elem.Text); } Assert.AreEqual(yearsReleased.Count, new HashSet <String>(yearsReleased).Count); }
public void TestChosenMultiple() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/chosen/index.html"); System.Threading.Thread.Sleep(2000); // wait enough time to load JS driver.FindElement(By.XPath("//div[@id='chosen_multiple_chosen']//li[@class='search-field']/input")).Click(); ReadOnlyCollection <IWebElement> available_items = driver.FindElements(By.XPath("//div[@id='chosen_multiple_chosen']//div[@class='chosen-drop']//li[contains(@class,'active-result')]")); foreach (IWebElement item in available_items) { if (item.Text.Equals("Australia")) { item.Click(); break; } } System.Threading.Thread.Sleep(1000); // select another driver.FindElement(By.XPath("//div[@id='chosen_multiple_chosen']//li[@class='search-field']/input")).Click(); available_items = driver.FindElements(By.XPath("//div[@id='chosen_multiple_chosen']//div[@class='chosen-drop']//li[contains(@class,'active-result')]")); foreach (IWebElement item in available_items) { if (item.Text.Equals("United Kingdom")) { item.Click(); break; } } System.Threading.Thread.Sleep(500); // clear all selections ReadOnlyCollection <IWebElement> closeButtons = driver.FindElements(By.XPath("//div[@id='chosen_multiple_chosen']//ul[@class='chosen-choices']/li[contains(@class,'search-choice')]/a[contains(@class,'search-choice-close')]")); foreach (IWebElement item in closeButtons) { item.Click(); } // then select one after clear driver.FindElement(By.XPath("//div[@id='chosen_multiple_chosen']//li[@class='search-field']/input")).Click(); available_items = driver.FindElements(By.XPath("//div[@id='chosen_multiple_chosen']//div[@class='chosen-drop']//li[contains(@class,'active-result')]")); foreach (IWebElement item in available_items) { if (item.Text.Equals("United States")) { item.Click(); break; } } }
public void TestCodeMirror() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/codemirror-5.1/demo/xmlcomplete.html"); System.Threading.Thread.Sleep(500); IWebElement elem = driver.FindElement(By.ClassName("CodeMirror-scroll")); elem.Click(); System.Threading.Thread.Sleep(500); // elem.sendKeys does not work Actions builder = new Actions(driver); builder.SendKeys("<h3>Heading 3</h3><p>TestWise is Selenium IDE</p>") .Perform(); }
public void TestSendSpecialKeys() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); IWebElement elem = driver.FindElement(By.Id("user")); elem.Clear(); elem.SendKeys("agileway"); System.Threading.Thread.Sleep(1000); // sleep for seeing the effect // select all (Ctrl+A) then press backspace elem.SendKeys(Keys.Control + "A"); elem.SendKeys(Keys.Backspace); System.Threading.Thread.Sleep(1000); elem.SendKeys("testwisely"); System.Threading.Thread.Sleep(1000); elem.SendKeys(Keys.Enter); //submit the form }
public void TestChosenSingle() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/chosen/index.html"); System.Threading.Thread.Sleep(2000); // wait enough time to load JS driver.FindElement(By.XPath("//div[@id='chosen_single_chosen']//a[contains(@class,'chosen-single')]")).Click(); ReadOnlyCollection <IWebElement> available_items = driver.FindElements(By.XPath("//div[@id='chosen_single_chosen']//div[@class='chosen-drop']//li[contains(@class,'active-result')]")); foreach (IWebElement item in available_items) { if (item.Text.Equals("Australia")) { item.Click(); break; } } System.Threading.Thread.Sleep(1000); driver.FindElement(By.XPath("//div[@id='chosen_single_chosen']//a[contains(@class,'chosen-single')]")).Click(); available_items = driver.FindElements(By.XPath("//div[@id='chosen_single_chosen']//div[@class='chosen-drop']//li[contains(@class,'active-result')]")); foreach (IWebElement item in available_items) { if (item.Text.Equals("United States")) { item.Click(); break; } } // Now search for an option System.Threading.Thread.Sleep(1000); driver.FindElement(By.XPath("//div[@id='chosen_single_chosen']//a[contains(@class,'chosen-single')]")).Click(); IWebElement search_text_field = driver.FindElement(By.XPath("//div[@id='chosen_single_chosen']//div[@class='chosen-drop']//div[contains(@class,'chosen-search')]/input")); search_text_field.SendKeys("United King"); System.Threading.Thread.Sleep(500); // let filtering finishing // select first selected option search_text_field.SendKeys(Keys.Enter); }
public void TestExtractDynamicTextUsingRegex() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/coupon.html"); driver.FindElement(By.Id("get_coupon_btn")).Click(); var couponText = driver.FindElement(By.Id("details")).Text; System.Console.WriteLine(couponText); Match match = Regex.Match(couponText, @"coupon code:\s+(\w+) used by\s([\d|-]+)"); if (match.Success) { string coupon = match.Groups[1].Value; string expiryDate = match.Groups[2].Value; // System.Console.WriteLine(expiryDate); // System.Console.WriteLine(coupon); driver.FindElement(By.Name("coupon")).SendKeys(coupon); } else { throw new Exception("Error: no valid coupon returned"); } }
public void TestRandomNumberForTextField() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); // a number between 10 and 99, will be different each run driver.FindElement(By.Name("username")).SendKeys("tester" + GetRandomNumber(10, 99)); }
public void Before() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/emberjs-crud-rest/index.html"); }
public void Before() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/angular_todo.html"); }
public void Before() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); }
public void Before() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/radio_button.html"); }
public void TestRandomStringForTextField() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); driver.FindElement(By.Name("password")).SendKeys(GetRandomString(8)); }
public void Before() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/index.html"); }
public void Before() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/select_list.html"); }
public void TestRandomStringInCollection() { driver.Navigate().GoToUrl(TestHelper.SiteUrl() + "/text_field.html"); String[] allowableStrings = new String[] { "Yes", "No", "Maybe" }; // one of these strings driver.FindElement(By.Name("username")).SendKeys(GetRandomStringIn(allowableStrings)); }