public void EditSubmit_ChangesChoiceDetails() { _driver.Navigate().GoToUrl(PollUrl); IReadOnlyCollection <IWebElement> editButtons = _driver.FindElements(By.ClassName("fa-pencil")); editButtons.First().Click(); IWebElement form = _driver.FindElement(By.Name("editChoiceForm")); IWebElement formName = _driver.FindElement(NgBy.Model("editChoiceForm.name")); IWebElement formDescription = _driver.FindElement(NgBy.Model("editChoiceForm.description")); string newName = "Changed Name"; string newDescription = "Changed Description"; formName.Clear(); formDescription.Clear(); formName.SendKeys(newName); formDescription.SendKeys(newDescription); IWebElement saveButton = _driver.FindElement(By.Id("dialog-save-button")); saveButton.Click(); Thread.Sleep(DialogClearWaitTime); IReadOnlyCollection <IWebElement> choiceNames = _driver.FindElements(NgBy.Binding("choice.Name")); IReadOnlyCollection <IWebElement> choiceDescriptions = _driver.FindElements(NgBy.Binding("choice.Description")); Assert.AreEqual(newName, choiceNames.First().Text); Assert.AreEqual(newDescription, choiceDescriptions.First().Text); }
private void SetSecond(string number) { var second = _ngDriver.FindElement(NgBy.Input("second")); second.Clear(); second.SendKeys(number); }
public void ShouldSortCustomersAccounts() { ngDriver.FindElement(NgBy.ButtonText("Bank Manager Login")).Click(); ngDriver.FindElement(NgBy.PartialButtonText("Customers")).Click(); wait.Until(ExpectedConditions.ElementExists(NgBy.Repeater("cust in Customers"))); // alterntive locator using core selenium wait.Until(ExpectedConditions.ElementExists(By.CssSelector("tr[ng-repeat*='cust in Customers']"))); IWebElement sort_link = ngDriver.FindElement(By.CssSelector("a[ng-click*='sortType'][ng-click*= 'fName']")); StringAssert.Contains("First Name", sort_link.Text); ngDriver.Highlight(sort_link, highlight_timeout); sort_link.Click(); ReadOnlyCollection <NgWebElement> ng_accounts = ngDriver.FindElements(NgBy.Repeater("cust in Customers")); // inspect first and last customers List <String> ng_account_names = ng_accounts.Select(element => element.Text).ToList(); String last_customer_name = ng_account_names.FindLast(element => true); ngDriver.Highlight(sort_link, highlight_timeout); sort_link.Click(); // confirm the customers are sorted in reverse order now StringAssert.Contains(last_customer_name, ngDriver.FindElements(NgBy.Repeater("cust in Customers")).First().Text); }
public void ClearCompleted() { AddToDo("ToDoToBeCleared"); AddToDo("SecondToDoToNotBeCleared"); NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list")); Assert.AreEqual(2, toDoList.FindElements(By.CssSelector("li")).Count, "to-do's weren't created"); NgWebElement item = toDoList.FindElement(By.CssSelector("li")); WebDriverWait wait = new WebDriverWait(ngDriver, new TimeSpan(0, 0, 15)); wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed")))); Assert.True(!item.GetAttribute("class").Contains("completed"), "item was already set to completed without being clicked"); item.FindElement(NgBy.Model("todo.completed")).Click(); Assert.True(item.GetAttribute("class").Contains("completed"), "item is still not to completed after it has been clicked"); wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("clear-completed"))); ngDriver.FindElement(By.Id("clear-completed")).Click(); Assert.AreEqual(1, toDoList.FindElements(By.CssSelector("li")).Count, "to-do wasn't deleted"); }
public void UncompleteToDo() { AddToDo("ToDoToBeSetBackToACtive"); NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list")); Assert.AreEqual(1, toDoList.FindElements(By.CssSelector("li")).Count, "to-do wasn't created"); NgWebElement item = toDoList.FindElement(By.CssSelector("li")); WebDriverWait wait = new WebDriverWait(ngDriver, new TimeSpan(0, 0, 15)); wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed")))); item.FindElement(NgBy.Model("todo.completed")).Click(); //issue was caused in edge attemted to fix with commented out code but basically the clicks whould happen too fast and the seond wouldnt be recognised Thread.Sleep(1000); Assert.True(item.GetAttribute("class").Contains("completed"), "to-do wasn't set to completed"); wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed")))); item.FindElement(NgBy.Model("todo.completed")).Click(); //ngDriver.WaitForAngular(); Assert.True(!item.GetAttribute("class").Contains("completed"), "to-do wasn't set to active"); }
// EnterText public static void Entertext(string webelementvalue, string value, propertytype elementtype) { switch (elementtype) { case propertytype.Model: PropertiesCollection.ngdriver.FindElement(NgBy.Model(webelementvalue)).SendKeys(value); break; case propertytype.Name: PropertiesCollection.ngdriver.FindElement(By.Name(webelementvalue)).SendKeys(value); break; case propertytype.XPath: PropertiesCollection.ngdriver.FindElement(By.XPath(webelementvalue)).SendKeys(value); break; case propertytype.CssSelector: PropertiesCollection.ngdriver.FindElement(By.CssSelector(webelementvalue)).SendKeys(value); break; case propertytype.Id: PropertiesCollection.ngdriver.FindElement(By.Id(webelementvalue)).SendKeys(value); break; } }
public void ShouldUpload() { Common.GetLocalHostPageContent("ng_upload1.htm"); // NOTE: does not work with Common.GetPageContent("ng_upload1.htm"); IWebElement file = driver.FindElement(By.CssSelector("div[ng-controller = 'myCtrl'] > input[type='file']")); Assert.IsNotNull(file); StringAssert.AreEqualIgnoringCase(file.GetAttribute("file-model"), "myFile"); String localPath = Common.CreateTempFile("lorem ipsum dolor sit amet"); IAllowsFileDetection fileDetectionDriver = driver as IAllowsFileDetection; if (fileDetectionDriver == null) { Assert.Fail("driver does not support file detection. This should not be"); } fileDetectionDriver.FileDetector = new LocalFileDetector(); try { file.SendKeys(localPath); } catch (WebDriverException e) { // the operation has timed out Console.Error.WriteLine(e.Message); } NgWebElement button = ngDriver.FindElement(NgBy.ButtonText("Upload")); button.Click(); NgWebElement ng_file = new NgWebElement(ngDriver, file); Object myFile = ng_file.Evaluate("myFile"); if (myFile != null) { Dictionary <String, Object> result = (Dictionary <String, Object>)myFile; Assert.IsTrue(result.Keys.Contains("name")); Assert.IsTrue(result.Keys.Contains("type")); Assert.IsTrue(result.Keys.Contains("size")); } else { Console.Error.WriteLine("myFile is null"); } String script = "var e = angular.element(arguments[0]); var f = e.scope().myFile; if (f){return f.name} else {return null;}"; try { Object result = ((IJavaScriptExecutor)driver).ExecuteScript(script, ng_file); if (result != null) { Console.Error.WriteLine(result.ToString()); } else { Console.Error.WriteLine("result is null"); } } catch (InvalidOperationException e) { Console.Error.WriteLine(e.Message); } }
public void ShouldHandleDeselectAngularUISelect() { Common.GetLocalHostPageContent("ng_ui_select_example1.htm"); ReadOnlyCollection <NgWebElement> ng_selected_colors = ngDriver.FindElements(NgBy.Repeater("$item in $select.selected")); while (true) { ng_selected_colors = ngDriver.FindElements(NgBy.Repeater("$item in $select.selected")); if (ng_selected_colors.Count == 0) { break; } NgWebElement ng_deselect_color = ng_selected_colors.Last(); Object itemColor = ng_deselect_color.Evaluate("$item"); Console.Error.WriteLine(String.Format("Deselecting color: {0}", itemColor.ToString())); IWebElement ng_close = ng_deselect_color.FindElement(By.CssSelector("span[class *='close']")); Assert.IsNotNull(ng_close); Assert.IsNotNull(ng_close.GetAttribute("ng-click")); StringAssert.IsMatch(@"removeChoice", ng_close.GetAttribute("ng-click")); ngDriver.Highlight(ng_close); ng_close.Click(); // ngDriver.waitForAngular(); } Console.Error.WriteLine("Nothing is selected"); }
// appears to be broken in PahtomJS / working in desktop browsers public void ShouldHandleMultiSelect() { Actions actions = new Actions(ngDriver.WrappedDriver); Common.GetLocalHostPageContent("ng_multi_select.htm"); IWebElement element = ngDriver.FindElement(NgBy.Model("selectedValues")); // use core Selenium IList <IWebElement> options = new SelectElement(element).Options; IEnumerator <IWebElement> etr = options.Where(o => Convert.ToBoolean(o.GetAttribute("selected"))).GetEnumerator(); while (etr.MoveNext()) { Console.Error.WriteLine(etr.Current.Text); } foreach (IWebElement option in options) { // http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/html/AllMembers_T_OpenQA_Selenium_Keys.htm actions.KeyDown(Keys.Control).Click(option).KeyUp(Keys.Control).Build().Perform(); // triggers ngDriver.WaitForAngular() Assert.IsNotEmpty(ngDriver.Url); } // re-read select options element = ngDriver.FindElement(NgBy.Model("selectedValues")); options = new SelectElement(element).Options; etr = options.Where(o => Convert.ToBoolean(o.GetAttribute("selected"))).GetEnumerator(); while (etr.MoveNext()) { Console.Error.WriteLine(etr.Current.Text); } }
// [Ignore("Ignore test to prevent exception crashing later tests")] public void ShouldFindElementByModel() { // NOTE: works with Angular 1.2.13, fails with Angular 1.4.9 Common.GetLocalHostPageContent("ng_pattern_validate.htm"); NgWebElement ng_input = ngDriver.FindElement(NgBy.Model("myVal")); ng_input.Clear(); NgWebElement ng_valid = ngDriver.FindElement(NgBy.Binding("form.value.$valid")); StringAssert.IsMatch("false", ng_valid.Text); NgWebElement ng_pattern = ngDriver.FindElement(NgBy.Binding("form.value.$error.pattern")); StringAssert.IsMatch("false", ng_pattern.Text); NgWebElement ng_required = ngDriver.FindElement(NgBy.Binding("!!form.value.$error.required")); StringAssert.IsMatch("true", ng_required.Text); ng_input.SendKeys("42"); Assert.IsTrue(ng_input.Displayed); ng_valid = ngDriver.FindElement(NgBy.Binding("form.value.$valid")); StringAssert.IsMatch("true", ng_valid.Text); ng_pattern = ngDriver.FindElement(NgBy.Binding("form.value.$error.pattern")); StringAssert.IsMatch("false", ng_pattern.Text); ng_required = ngDriver.FindElement(NgBy.Binding("!!form.value.$error.required")); StringAssert.IsMatch("false", ng_required.Text); }
public void ShouldFindRepeaterSelectedtOption() { Common.GetLocalHostPageContent("ng_repeat_selected.htm"); NgWebElement ng_element = ngDriver.FindElement(NgBy.SelectedRepeaterOption("fruit in Fruits")); StringAssert.IsMatch("Mango", ng_element.Text); }
public string GetResultsPhoneName(int index) { return(ngDriver.FindElements(NgBy.Repeater("phone in $ctrl.phones"))[index].Evaluate("phone.name") as string); // phone-list.template.html // {{phone.name}} // {{phone.snippet}} }
public void HelloNgDriver() { NgWebElement ngElement = _ngWebDriver.FindElement(NgBy.Model("q")); ngElement.Clear(); ngElement.SendKeys("Hello NgWebDriver"); }
public void ShouldDropDown() { GetPageContent("ng_dropdown.htm"); string optionsCountry = "country for (country, states) in countries"; ReadOnlyCollection <NgWebElement> ng_countries = ngDriver.FindElements(NgBy.Options(optionsCountry)); Assert.IsTrue(4 == ng_countries.Count); Assert.IsTrue(ng_countries[0].Enabled); string optionsState = "state for (state,city) in states"; NgWebElement ng_state = ngDriver.FindElement(NgBy.Options(optionsState)); Assert.IsFalse(ng_state.Enabled); SelectElement countries = new SelectElement(ngDriver.FindElement(NgBy.Model("states")).WrappedElement); countries.SelectByText("Australia"); Thread.Sleep(1000); Assert.IsTrue(ng_state.Enabled); NgWebElement ng_selected_country = ngDriver.FindElement(NgBy.SelectedOption(optionsCountry)); // TODO:debug (works in Java client) // Assert.IsNotNull(ng_selected_country.WrappedElement); // ng_countries = ngDriver.FindElements(NgBy.Options(optionsCountry)); NgWebElement ng_country = ng_countries.First(o => o.Selected); StringAssert.IsMatch("Australia", ng_country.Text); }
public void ShouldWaitForAngular() { ngDriver.Navigate().GoToUrl(base_url); IWebElement element = ngDriver.FindElement(NgBy.Model("yourName")); Assert.IsTrue(((NgWebElement)element).Displayed); }
public void ShouldAdd() { StringAssert.AreEqualIgnoringCase(ngDriver.Title, "Super Calculator"); var ng_first_operand = ngDriver.FindElement(NgBy.Model("first")); ng_first_operand.SendKeys("1"); NgWebElement ng_second_operand = ngDriver.FindElement(NgBy.Input("second")); ng_second_operand.SendKeys("2"); NgWebElement ng_math_operator_element = ngDriver.FindElement(NgBy.Options("value for (key, value) in operators")); Assert.AreEqual(ng_math_operator_element.Text, "+"); IWebElement math_operator_element = ngDriver.FindElement(NgBy.SelectedOption("operator")); Assert.AreEqual(math_operator_element.Text, "+"); IWebElement go_button_element = ngDriver.FindElement(NgBy.PartialButtonText("Go")); Assert.IsTrue(go_button_element.Displayed); var ng_go_button_element = ngDriver.FindElement(By.Id("gobutton")); ng_go_button_element.Click(); NgWebElement result_element = ngDriver.FindElement(NgBy.Binding("latest")); Assert.AreEqual("3", result_element.Text); highlight(result_element, 1000); }
public static void clickable(string webelementvalue, propertytype elementtype) { if (elementtype == propertytype.Model) { PropertiesCollection.ngdriver.FindElement(NgBy.Model(webelementvalue)).Click(); } else if (elementtype == propertytype.Name) { PropertiesCollection.ngdriver.FindElement(By.Name(webelementvalue)).Click(); } else if (elementtype == propertytype.XPath) { PropertiesCollection.ngdriver.FindElement(By.XPath(webelementvalue)).Click(); } else if (elementtype == propertytype.CssSelector) { PropertiesCollection.ngdriver.FindElement(By.CssSelector(webelementvalue)).Click(); } else if (elementtype == propertytype.Class) { PropertiesCollection.ngdriver.FindElement(By.ClassName(webelementvalue)).Click(); } else if (elementtype == propertytype.LinkText) { PropertiesCollection.ngdriver.FindElement(By.LinkText(webelementvalue)).Click(); } }
public static string GettextfromLabel(string webelementvalue, propertytype elementtype) { if (elementtype == propertytype.Model) { return(PropertiesCollection.ngdriver.FindElement(NgBy.Model(webelementvalue)).Text); } else if (elementtype == propertytype.Name) { return(PropertiesCollection.ngdriver.FindElement(By.Name(webelementvalue)).Text); } else if (elementtype == propertytype.XPath) { return(PropertiesCollection.ngdriver.FindElement(By.XPath(webelementvalue)).Text); } else if (elementtype == propertytype.CssSelector) { return(PropertiesCollection.ngdriver.FindElement(By.CssSelector(webelementvalue)).Text); } else if (elementtype == propertytype.LinkText) { return(PropertiesCollection.ngdriver.FindElement(By.CssSelector(webelementvalue)).Text); } return(string.Empty); }
// click button, checkbox,radio buttion,check boxal public static void click(string webelementvalue, propertytype elementtype) { switch (elementtype) { case propertytype.Model: PropertiesCollection.ngdriver.FindElement(NgBy.Model(webelementvalue)).Click(); break; case propertytype.Name: PropertiesCollection.ngdriver.FindElement(By.Name(webelementvalue)).Click(); break; case propertytype.XPath: PropertiesCollection.ngdriver.FindElement(By.XPath(webelementvalue)).Click(); break; case propertytype.CssSelector: PropertiesCollection.ngdriver.FindElement(By.CssSelector(webelementvalue)).Click(); break; case propertytype.Class: PropertiesCollection.ngdriver.FindElement(By.ClassName(webelementvalue)).Click(); break; case propertytype.LinkText: PropertiesCollection.ngdriver.FindElement(By.LinkText(webelementvalue)).Click(); break; } }
public static string Geettextfromtextbox(string webelementvalue, propertytype elementtype) { if (elementtype == propertytype.Model) { return(PropertiesCollection.ngdriver.FindElement(NgBy.Model(webelementvalue)).GetAttribute("value")); } else if (elementtype == propertytype.Name) { return(PropertiesCollection.ngdriver.FindElement(By.Name(webelementvalue)).GetAttribute("value")); } else if (elementtype == propertytype.XPath) { return(PropertiesCollection.ngdriver.FindElement(By.XPath(webelementvalue)).GetAttribute("value")); } else if (elementtype == propertytype.CssSelector) { return(PropertiesCollection.ngdriver.FindElement(By.CssSelector(webelementvalue)).GetAttribute("value")); } else { return(string.Empty); } }
public void ShouldDragAndDrop() { Common.GetLocalHostPageContent("ng_drag_and_drop1.htm"); ReadOnlyCollection <NgWebElement> ng_cars = ngDriver.FindElements(NgBy.Repeater("car in models.cars")); Assert.AreEqual(5, ng_cars.Count); foreach (NgWebElement ng_car in ng_cars) { try { ngDriver.Highlight(ng_car); actions.MoveToElement(ng_car).Build().Perform(); IWebElement basket = driver.FindElement(By.XPath("//*[@id='my-basket']")); // works in Java, desktop browser actions.ClickAndHold(ng_car).MoveToElement(basket).Release().Build() .Perform(); Thread.Sleep(1000); NgWebElement ng_basket = new NgWebElement(ngDriver, basket); ReadOnlyCollection <NgWebElement> ng_cars_basket = ng_basket.FindElements(NgBy.Repeater("car in models.basket")); NgWebElement ng_car_basket = ng_cars_basket.Last(); Assert.IsTrue(ng_car_basket.Displayed); // {{ car.name }} - {{ car.modelYear }} ( {{ car.price | currency }} ) Console.Error.WriteLine("%s - %s ( %s )", ng_car_basket.Evaluate("car.name"), ng_car_basket.Evaluate("car.modelYear"), ng_car_basket.Evaluate("car.price | currency")); } catch (Exception e) { // System.InvalidOperationException: Sequence contains no elements // TODO Console.Error.WriteLine(e.ToString()); } } }
public void PointsButtons_ChangePointAllocations() { using (IWebDriver driver = Driver) { using (var context = new TestVotingContext()) { Poll poll = CreatePoll(context); GoToUrl(driver, PollUrl); IReadOnlyCollection <IWebElement> choices = driver.FindElements(NgBy.Repeater("choice in choices")); IWebElement firstChoice = choices.First(); IWebElement selectedChoicePoints = firstChoice.FindElement(NgBy.Binding("choice.VoteValue")); IReadOnlyCollection <IWebElement> increaseChoiceButtons = FindElementsById(driver, "increase-button"); IWebElement plusButton = increaseChoiceButtons.First(); IReadOnlyCollection <IWebElement> decreaseChoiceButtons = FindElementsById(driver, "decrease-button"); IWebElement minusButton = decreaseChoiceButtons.First(); string noPointsAllocatedPointsValue = "0 / " + poll.MaxPerVote; Assert.AreEqual(noPointsAllocatedPointsValue, selectedChoicePoints.Text); plusButton.Click(); string onePointAllocatedPointsValue = "1 / " + poll.MaxPerVote; Assert.AreEqual(onePointAllocatedPointsValue, selectedChoicePoints.Text); minusButton.Click(); Assert.AreEqual(noPointsAllocatedPointsValue, selectedChoicePoints.Text); } } }
public void FilterByCompleted() { AddToDo("ToDoToBeFiltered"); AddToDo("SecondToDoToNotBeFiltered"); NgWebElement toDoList = ngDriver.FindElement(By.Id("todo-list")); Assert.AreEqual(2, toDoList.FindElements(By.CssSelector("li")).Count, "to-do's weren't created"); NgWebElement item = toDoList.FindElement(By.CssSelector("li")); Assert.True(!item.GetAttribute("class").Contains("completed"), "item was already set to completed without being clicked"); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementToBeClickable(item.FindElement(NgBy.Model("todo.completed")))); item.FindElement(NgBy.Model("todo.completed")).Click(); Assert.True(item.GetAttribute("class").Contains("completed"), "item is still not to completed after it has been clicked"); NgWebElement filters = ngDriver.FindElement(By.Id("filters")); filters.FindElement(By.CssSelector("a[href='#/completed']")).Click(); //changing the filter reloaded the todo list from scratch causing a stale todo list element Assert.AreEqual(1, ngDriver.FindElement(By.Id("todo-list")).FindElements(By.CssSelector("li")).Count, "to-do wasn't filtered"); }
public void ShouldFilter() { // Fake backend with 2 phones NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET('phones/phones.json').respond( [ { age: 12, carrier: 'AT&T', id: 'motorola-bravo-with-motoblur', imageUrl: 'img/phones/motorola-bravo-with-motoblur.0.jpg', name: 'MOTOROLA BRAVO\u2122 with MOTOBLUR\u2122', snippet: 'An experience to cheer about.' }, { age: 13, carrier: 'T-Mobile', id: 'motorola-defy-with-motoblur', imageUrl: 'img/phones/motorola-defy-with-motoblur.0.jpg', name: 'Motorola DEFY\u2122 with MOTOBLUR\u2122', snippet: 'Are you ready for everything life throws your way?' }, ] ); "); IWebDriver ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://angular.github.io/angular-phonecat/step-5/app/"); Assert.AreEqual(2, ngDriver.FindElements(NgBy.Repeater("phone in phones")).Count); ngDriver.FindElement(NgBy.Input("query")).SendKeys("bravo"); Assert.AreEqual(1, ngDriver.FindElements(NgBy.Repeater("phone in phones")).Count); ngDriver.FindElement(NgBy.Input("query")).SendKeys("!"); Assert.AreEqual(0, ngDriver.FindElements(NgBy.Repeater("phone in phones")).Count); }
private void SetFirst(string number) { var first = _ngDriver.FindElement(NgBy.Input("first")); first.Clear(); first.SendKeys(number); }
public void ShouldEvaluateTransactionDetails() { ngDriver.FindElement(NgBy.ButtonText("Customer Login")).Click(); // select customer/account with transactions ngDriver.FindElement(NgBy.Model("custId")).FindElements(NgBy.Repeater("cust in Customers")).First(cust => Regex.IsMatch(cust.Text, "Hermoine Granger")).Click(); ngDriver.FindElement(NgBy.ButtonText("Login")).Click(); ngDriver.FindElements(NgBy.Options("account for account in Accounts")).First(account => Regex.IsMatch(account.Text, "1001")).Click(); // switch to transactions NgWebElement ng_transaction_button = ngDriver.FindElement(NgBy.PartialButtonText("Transactions")); StringAssert.Contains("Transactions", ng_transaction_button.Text); ngDriver.Highlight(ng_transaction_button); ng_transaction_button.Click(); // wait for transaction information to be loaded and rendered wait.Until(ExpectedConditions.ElementExists(NgBy.Repeater("tx in transactions"))); // examine first few transactions using Evaluate ReadOnlyCollection <NgWebElement> ng_transactions = ngDriver.FindElements(NgBy.Repeater("tx in transactions")); int cnt = 0; foreach (NgWebElement ng_current_transaction in ng_transactions) { if (cnt++ > 5) { break; } StringAssert.IsMatch("(?i:credit|debit)", ng_current_transaction.Evaluate("tx.type").ToString()); StringAssert.IsMatch(@"(?:\d+)", ng_current_transaction.Evaluate("tx.amount").ToString()); // 'tx.date' is in Javascript UTC format similar to UniversalSortableDateTimePattern in C# var transaction_date = ng_current_transaction.Evaluate("tx.date"); StringAssert.IsMatch(@"(?:\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z)", transaction_date.ToString()); } }
public void ShouldAddFriend() { StringAssert.AreEqualIgnoringCase(ngDriver.Title, "Angular JS Demo"); String friendName = "John Doe"; int friendCount = ngDriver.FindElements(NgBy.Repeater("row in rows")).Count; NgWebElement addnameBox = ngDriver.FindElement(NgBy.Model("addName")); Assert.IsNotNull(addnameBox); ngDriver.Highlight(addnameBox, highlight_timeout); addnameBox.SendKeys(friendName); // add the friend NgWebElement addButton = ngDriver.FindElement(NgBy.ButtonText("+ add")); Assert.IsNotNull(addButton); ngDriver.Highlight(addButton, highlight_timeout); addButton.Click(); // confirm the number of friends Assert.AreEqual(1, ngDriver.FindElements(NgBy.Repeater("row in rows")).Count - friendCount); // find friend NgWebElement addedFriendElement = ngDriver.FindElements(NgBy.CssContainingText("td.ng-binding", friendName)).First(); Assert.IsNotNull(addedFriendElement); ngDriver.Highlight(addedFriendElement, highlight_timeout); Console.Error.WriteLine("Added friend name: " + addedFriendElement.Text); }
public void ShouldListTodos() { var elements = ngDriver.FindElements(NgBy.Repeater("todo in todoList.todos")); Assert.AreEqual("build an AngularJS app", elements[1].Text); Assert.AreEqual(false, elements[1].Evaluate("todo.done")); }
public void ShouldListTransactions() { ngDriver.FindElement(NgBy.ButtonText("Customer Login")).Click(); // select customer/account with transactions ngDriver.FindElement(NgBy.Model("custId")).FindElements(NgBy.Repeater("cust in Customers")).First(cust => Regex.IsMatch(cust.Text, "Hermoine Granger")).Click(); ngDriver.FindElement(NgBy.ButtonText("Login")).Click(); ngDriver.FindElements(NgBy.Options("account for account in Accounts")).First(account => Regex.IsMatch(account.Text, "1001")).Click(); // switch to transactions NgWebElement ng_transaction_button = ngDriver.FindElement(NgBy.PartialButtonText("Transactions")); StringAssert.Contains("Transactions", ng_transaction_button.Text); ngDriver.Highlight(ng_transaction_button, highlight_timeout); ng_transaction_button.Click(); // http://www.way2automation.com/angularjs-protractor/banking/listTx.html // wait for transaction information to be loaded and rendered wait.Until(ExpectedConditions.ElementExists(NgBy.Repeater("tx in transactions"))); // highlight transaction type cells in the page differently for Credit or Debit using RepeaterColumn ReadOnlyCollection <NgWebElement> ng_transaction_type_columns = ngDriver.FindElements(NgBy.RepeaterColumn("tx in transactions", "tx.type")); Assert.IsNotEmpty(ng_transaction_type_columns); foreach (NgWebElement ng_current_transaction_type in ng_transaction_type_columns) { if (String.IsNullOrEmpty(ng_current_transaction_type.Text)) { break; } ngDriver.Highlight(ng_current_transaction_type, highlight_timeout, 3, ng_current_transaction_type.Text.Equals("Credit") ? "green" : "blue"); } }
public void AddButtonWithoutAddAnotherToggle_ClosesForm() { _driver.Navigate().GoToUrl(PollUrl); IWebElement addChoiceButton = _driver.FindElement(By.PartialLinkText("New Choice")); addChoiceButton.Click(); Thread.Sleep(DialogClearWaitTime); IWebElement formName = _driver.FindElement(NgBy.Model("addChoiceForm.name")); formName.SendKeys("Test"); IWebElement addAnotherCheckbox = _driver.FindElement(By.Id("add-another-checkbox")); addAnotherCheckbox.Click(); IWebElement addButton = _driver.FindElement(By.Id("add-button")); addButton.Click(); Thread.Sleep(DialogClearWaitTime); formName = _driver.FindElement(NgBy.Model("addChoiceForm.name")); Assert.IsFalse(formName.IsVisible()); }