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); }
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 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"); }
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 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 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 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 NoCustomersOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [], // headers { 'X-InlineCount': 0 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var cardElement = ngDriver.FindElement(By.ClassName("cardContainer")); Assert.AreEqual(0, cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")).Count); Assert.IsTrue(ngDriver.FindElement(By.XPath("//h4[contains(.,'No customers found')]")).Displayed); }
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 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 ShouldListTodos() { NgDriver.Navigate().GoToUrl("http://www.angularjs.org"); var elements = NgDriver.FindElements(NgBy.Repeater("todo in todoList.todos")); Assert.AreEqual("build an AngularJS app", elements[1].Text.Trim()); Assert.AreEqual(false, elements[1].Evaluate("todo.done")); }
public void PerformNgByRepeaterAction() { driver.Navigate().GoToUrl(base_url); ngDriver.Url = driver.Url; ngDriver.FindElement(By.CssSelector("[ng-click='customer()']")).Click(); var ng_customers = ngDriver.FindElements(NgBy.Repeater("cust in Customers")); ng_customers[3].Click(); }
public void ShouldFindRows() { Common.GetLocalHostPageContent("ng_repeat_start_end.htm"); ReadOnlyCollection <NgWebElement> elements = ngDriver.FindElements(NgBy.Repeater("definition in definitions")); Assert.IsTrue(elements[0].Displayed); StringAssert.AreEqualIgnoringCase(elements[0].Text, "Foo"); }
public void ShouldListTodos() { var ngDriver = new NgWebDriver(_driver); ngDriver.Navigate().GoToUrl("http://www.angularjs.org"); var elements = ngDriver.FindElements(NgBy.Repeater("todo in todoList.todos")); Assert.AreEqual("build an angular app", elements[1].Text); Assert.AreEqual(false, elements[1].Evaluate("todo.done")); }
public void ShouldHandleFluentExceptions() { Common.GetLocalHostPageContent("ng_repeat_start_end.htm"); Action a = () => { var displayed = ngDriver.FindElement(NgBy.Repeater("this is not going to be found")).Displayed; }; // NoSuchElement Exception is not thrown by Protractor // a.ShouldThrow<NoSuchElementException>().WithMessage("Could not find element by: NgBy.Repeater:"); a.ShouldThrow <NullReferenceException>(); }
public void ProtractorTestUsingCSharp() { ngDriver.FindElement(NgBy.Binding("BindingName")).Click(); ngDriver.FindElement(NgBy.Model("ModelName")).SendKeys("Text"); ngDriver.FindElement(NgBy.Repeater("Value")).Click(); ngDriver.FindElement(NgBy.SelectedOption("Options")).Click(); ngDriver.FindElement(By.ClassName("ClassName")).SendKeys("Text"); ngDriver.FindElement(By.TagName("Tag")).Click(); ngDriver.FindElement(By.CssSelector("#CssSelector")).Click(); ngDriver.FindElement(By.Id("Id")).Click(); }
public void DeleteButton_RemovesChoice() { _driver.Navigate().GoToUrl(PollUrl); IReadOnlyCollection <IWebElement> deleteButtons = _driver.FindElements(By.ClassName("fa-trash-o")); deleteButtons.First().Click(); IReadOnlyCollection <IWebElement> choices = _driver.FindElements(NgBy.Repeater("choice in choices")); Assert.AreEqual(_defaultPoll.Choices.Count - 1, choices.Count); }
public void ShouldThrowfluentExceptions() { GetPageContent("ng_repeat_start_end.htm"); // Potentially a useful Assert for Page Object - heavy projects. Does not work very well with Protractor Action a = () => { var displayed = ngDriver.FindElement(NgBy.Repeater("this is not going to be found")).Displayed; }; a.ShouldThrow <NoSuchElementException>().WithMessage("Could not find element by: NgBy.Repeater:"); }
public CustomerOrdersPage GoToCustomerOrders(int customerId) { var viewElement = IsCardViewSelected() ? cardViewElement : listViewElement; foreach (var customer in viewElement.FindElements(NgBy.Repeater("customer in filteredCustomers"))) { if ((long)customer.Evaluate("customer.id") == customerId) { customer.FindElement(NgBy.Binding("customer.orderCount")).Click(); break; } } return(new CustomerOrdersPage(ngDriver)); }
public void ShowTop10Customers() { IWebDriver ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); IWebElement cardElement = ngDriver.FindElement(By.ClassName("cardContainer")); var customers = cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")); Assert.AreEqual(10, customers.Count); IWebElement footer = ngDriver.FindElement(NgBy.Binding("totalRecords")); Assert.AreEqual("Showing 10 of 23 total customers", footer.Text); }
public AngularDirectivePage ClickAngularDirective() { //This line is needed in order the NgDriver to know that this is going to be an Angular page //Going forward we will re-factor this. NgWebDriver ngDriver = new NgWebDriver(NgDriver.WrappedDriver, "[ng-app='docsApp']"); IList <NgWebElement> eList = NgDriver.FindElements(NgBy.Repeater("navItem in navGroup.navItems")); foreach (NgWebElement ngWebElement in eList.Where(ngWebElement => ngWebElement.FindElement(By.XPath("//a[.='directive']")).Displayed)) { ngWebElement.Click(); break; } return(new AngularDirectivePage(ngDriver)); }
public void ShouldDeleteCustomer() { // switch to "Add Customer" screen ngDriver.FindElement(NgBy.ButtonText("Bank Manager Login")).Click(); ngDriver.FindElement(NgBy.PartialButtonText("Add Customer")).Click(); // fill new Customer data ngDriver.FindElement(NgBy.Model("fName")).SendKeys("John"); ngDriver.FindElement(NgBy.Model("lName")).SendKeys("Doe"); ngDriver.FindElement(NgBy.Model("postCd")).SendKeys("11011"); // NOTE: there are two 'Add Customer' buttons on this form NgWebElement ng_add_customer_button = ngDriver.FindElements(NgBy.PartialButtonText("Add Customer"))[1]; actions.MoveToElement(ng_add_customer_button.WrappedElement).Build().Perform(); ngDriver.Highlight(ng_add_customer_button); ng_add_customer_button.Submit(); // confirm ngDriver.WrappedDriver.SwitchTo().Alert().Accept(); // switch to "Home" screen ngDriver.FindElement(NgBy.ButtonText("Home")).Click(); ngDriver.FindElement(NgBy.ButtonText("Bank Manager Login")).Click(); ngDriver.FindElement(NgBy.PartialButtonText("Customers")).Click(); // found new customer ReadOnlyCollection <NgWebElement> ng_customers = ngDriver.FindElements(NgBy.Repeater("cust in Customers")); // collect all customers ReadOnlyCollection <NgWebElement> ng_users = ngDriver.FindElements(NgBy.RepeaterColumn("cust in Customers", "user")); NgWebElement new_customer = ng_customers.Single(cust => Regex.IsMatch(cust.Text, "John Doe")); Assert.IsNotNull(new_customer); // remove button NgWebElement ng_delete_customer_button = new_customer.FindElement(NgBy.ButtonText("Delete")); StringAssert.IsMatch("Delete", ng_delete_customer_button.Text); actions.MoveToElement(ng_delete_customer_button.WrappedElement).Build().Perform(); ng_delete_customer_button.Click(); // confirm the cusomer is no loger present ng_customers = ngDriver.FindElements(NgBy.Repeater("cust in Customers")); IEnumerable <NgWebElement> removed_customer = ng_customers.TakeWhile(cust => Regex.IsMatch(cust.Text, "John Doe.*")); Assert.IsEmpty(removed_customer); }
public void Given_I_have_entered_P0_into_the_search_bar(string city) { //Send city to search box and set active var search = _ngDriver.FindElement(By.XPath("//input[@name='search']")); search.SendKeys(city); search.Click(); _ngDriver.WaitForAngular(); //Verify Selected Element is Correct, if not select if (_ngDriver.FindElement(NgBy.Binding("getPresName($index)")).Text.ToLower() != city.ToLower()) { _ngDriver.FindElements(NgBy.Repeater("item in results | limitTo:10")). First(x => x.Text == city).Click(); } }
public void GetRepeaterButton(string name, int index, By locator) { //ngDriver.FindElements(NgBy.Repeater(name)).ElementAt(index).FindElement(locator).Click(); _wait.Until(d => { try { ngDriver.FindElements(NgBy.Repeater(name)).ElementAt(index).FindElement(locator).Click(); return(true); } catch { return(false); } }); }
public void ShouldChangeSelectedtOption() { Common.GetLocalHostPageContent("ng_select_array.htm"); ReadOnlyCollection <NgWebElement> ng_elements = ngDriver.FindElements(NgBy.Repeater("option in options")); NgWebElement ng_element = ng_elements.First(o => String.Compare("two", o.Text, StringComparison.InvariantCulture) == 0); ng_element.Click(); string text = ng_element.Text; // to trigger WaitForAngular Assert.IsTrue(ng_element.Displayed); ng_element = ngDriver.FindElement(NgBy.SelectedOption("myChoice")); StringAssert.IsMatch(text, ng_element.Text); Assert.IsTrue(ng_element.Displayed); }
public void ShouldSelectAll() { // Given multuselect directive NgWebElement ng_directive = ngDriver.FindElement(NgBy.Model("selectedCar")); Assert.IsNotNull(ng_directive.WrappedElement); Assert.That(ng_directive.TagName, Is.EqualTo("am-multiselect")); // open am-multiselect IWebElement toggleSelect = ng_directive.FindElement(NgBy.ButtonText("Select Some Cars")); Assert.IsNotNull(toggleSelect); Assert.IsTrue(toggleSelect.Displayed); toggleSelect.Click(); // When using 'check all' link wait.Until(o => (o.FindElements(By.CssSelector("button[ng-click='checkAll()']")).Count != 0)); IWebElement check_all = ng_directive.FindElement(By.CssSelector("button[ng-click='checkAll()']")); Assert.IsTrue(check_all.Displayed); ngDriver.Highlight(check_all, highlight_timeout, 5, "blue"); check_all.Click(); // Then every car is selected // validatate the count ReadOnlyCollection <NgWebElement> cars = ng_directive.FindElements(NgBy.Repeater("i in items")); Assert.AreEqual(cars.Count(), cars.Count(car => (Boolean)car.Evaluate("i.checked"))); // walk over foreach (NgWebElement ng_item in ng_directive.FindElements(NgBy.RepeaterColumn("i in items", "i.label"))) { if (Boolean.Parse(ng_item.Evaluate("i.checked").ToString())) { IWebElement icon = ng_item.FindElement(By.ClassName("glyphicon")); // NOTE: the icon attributes // <i class="glyphicon glyphicon-ok" ng-class="{'glyphicon-ok': i.checked, 'empty': !i.checked}"></i> StringAssert.Contains("{'glyphicon-ok': i.checked, 'empty': !i.checked}", icon.GetAttribute("ng-class")); Console.Error.WriteLine("Icon: " + icon.GetAttribute("class")); ngDriver.Highlight(ng_item, highlight_timeout); } } Thread.Sleep(1000); }
public void ShouldFindOrderByField() { Common.GetLocalHostPageContent("ng_headers_sort_example1.htm"); String[] headers = new String[] { "First Name", "Last Name", "Age" }; foreach (String header in headers) { IWebElement headerelement = ngDriver.FindElement(By.XPath(String.Format("//th/a[contains(text(),'{0}')]", header))); Console.Error.WriteLine(header); headerelement.Click(); // to trigger WaitForAngular Assert.IsNotEmpty(ngDriver.Url); IWebElement emp = ngDriver.FindElement(NgBy.Repeater("emp in data.employees")); NgWebElement ngRow = new NgWebElement(ngDriver, emp); String orderByField = emp.GetAttribute("ng-order-by"); Console.Error.WriteLine(orderByField + ": " + ngRow.Evaluate(orderByField).ToString()); } }
public void ShouldChangeSelectedtOption() { ReadOnlyCollection <NgWebElement> options = ngDriver.FindElements(NgBy.Repeater("option in options")); var options_enumerator = options.GetEnumerator(); options_enumerator.Reset(); while (options_enumerator.MoveNext()) { NgWebElement option = (NgWebElement)options_enumerator.Current; if (option.Text.Equals("two", StringComparison.Ordinal)) { option.Click(); } } NgWebElement element = ngDriver.FindElement(NgBy.SelectedOption("myChoice")); StringAssert.IsMatch("two", element.Text); }
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, highlight_timeout); 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()); // NOTE: need to evaluate full expression - Evaluate("tx.date") returns an empty Dictionary string transaction_datetime = ng_current_transaction.Evaluate(" tx.date | date:'medium'").ToString(); DateTime dt; try { CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US"); DateTimeStyles styles = DateTimeStyles.AllowWhiteSpaces; dt = DateTime.Parse(transaction_datetime, culture, styles); } catch (FormatException) { Console.WriteLine("Unable to parse datetime '{0}'.", transaction_datetime); throw; } } }
public void ShouldChangeRepeaterSelectedtOption() { Common.GetLocalHostPageContent("ng_repeat_selected.htm"); NgWebElement ng_element = ngDriver.FindElement(NgBy.SelectedRepeaterOption("fruit in Fruits")); StringAssert.IsMatch("Mango", ng_element.Text); ReadOnlyCollection <NgWebElement> ng_elements = ngDriver.FindElements(NgBy.Repeater("fruit in Fruits")); ng_element = ng_elements.First(o => String.Compare("Orange", o.Text, StringComparison.InvariantCulture) == 0); ng_element.Click(); string text = ng_element.Text; // to trigger WaitForAngular Assert.IsTrue(ng_element.Displayed); // reload ng_element = ngDriver.FindElement(NgBy.SelectedRepeaterOption("fruit in Fruits")); StringAssert.IsMatch("Orange", ng_element.Text); }