public void ShouldGreetUsingBinding() { IWebDriver ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl("http://www.angularjs.org"); ngDriver.FindElement(NgBy.Model("yourName")).SendKeys("Julie"); Assert.AreEqual("Hello Julie!", ngDriver.FindElement(NgBy.Binding("yourName")).Text); }
public void Then_I_should_be_taken_to_the_weather_page_for_P0(string city) { //Assert Page loaded is correct _ngDriver.FindElement(NgBy.Binding("locationTitle")).Click(); Assert.IsTrue (_ngDriver.FindElement(NgBy.Binding("locationTitle")).Text.ToLower().Trim() .Contains (city.ToLower().Trim())); }
public void ShouldGreetUsingBinding() { // Instanciate a classic Selenium's WebDriver //var driver = new ChromeDriver(); // Configure timeouts (important since Protractor uses asynchronous client side scripts) //driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5)); NgDriver.Navigate().GoToUrl("http://www.angularjs.org"); NgDriver.FindElement(NgBy.Model("yourName")).SendKeys("Julie"); Assert.AreEqual("Hello Julie!", NgDriver.FindElement(NgBy.Binding("yourName")).Text);//} }
public void DisplaysChoiceNames() { _driver.Navigate().GoToUrl(PollUrl); IReadOnlyCollection <IWebElement> choiceNames = _driver.FindElements(NgBy.Binding("choice.Name")); Assert.AreEqual(_defaultPoll.Choices.Count, choiceNames.Count); CollectionAssert.AreEquivalent(_defaultPoll.Choices.Select(o => o.Name).ToList(), choiceNames.Select(o => o.Text).ToList()); }
public void NameSection_DisplaysCurrentName() { _driver.Navigate().GoToUrl(PollUrl); IWebElement manageNameSection = _driver.FindElement(By.Id("manage-name-section")); IWebElement pollName = manageNameSection.FindElement(NgBy.Binding("Question")); Assert.IsTrue(pollName.IsVisible()); Assert.AreEqual(_defaultPoll.Name, pollName.Text); }
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 ShouldGreetUsingBinding() { var ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl("http://www.angularjs.org"); ngDriver.FindElement(NgBy.Model("yourName")).SendKeys("Rupesh"); Assert.AreEqual("Hello Rupesh!", ngDriver.FindElement(NgBy.Binding("yourName")).Text); //driver.Url = "http://www.angularjs.org"; //driver.FindElement(By.CssSelector("input.ng-valid.ng-touched.ng-dirty.ng-valid-parse.ng-empty")).SendKeys("Rupesh"); //NoSuchElementException }
public string GetFooterText() { var noCustomersFooterElement = ngDriver.FindElement(By.XPath("//div[@data-ng-show='customers.length == 0']")); if (noCustomersFooterElement.Displayed) { return(noCustomersFooterElement.Text); } else { return(ngDriver.FindElement(NgBy.Binding("totalRecords")).Text); } }
public void ShouldWithdraw() { ShouldDeposit(); int account_balance = -1; int.TryParse(ngDriver.FindElement(NgBy.Binding("amount")).Text.FindMatch(@"(?<account_balance>\d+)$"), out account_balance); Assert.AreNotEqual(-1, account_balance); ngDriver.FindElement(NgBy.PartialButtonText("Withdrawl")).Click(); // core Selenium Thread.Sleep(1000); wait.Until(ExpectedConditions.ElementExists(By.CssSelector("form[name='myForm']"))); NgWebElement ng_form_element = new NgWebElement(ngDriver, driver.FindElement(By.CssSelector("form[name='myForm']"))); NgWebElement ng_withdrawl_amount = ng_form_element.FindElement(NgBy.Model("amount")); ng_withdrawl_amount.SendKeys((account_balance + 100).ToString()); NgWebElement ng_withdrawl_button = ng_form_element.FindElement(NgBy.ButtonText("Withdraw")); ngDriver.Highlight(ng_withdrawl_button, highlight_timeout); ng_withdrawl_button.Click(); // inspect message var ng_message = ngDriver.FindElement(NgBy.Binding("message")); StringAssert.Contains("Transaction Failed. You can not withdraw amount more than the balance.", ng_message.Text); ngDriver.Highlight(ng_message); // re-read the amount int updated_account_balance = -1; int.TryParse(ngDriver.FindElement(NgBy.Binding("amount")).Text.FindMatch(@"(?<account_balance>\d+)$"), out updated_account_balance); Assert.AreEqual(account_balance, updated_account_balance); // core Selenium Thread.Sleep(1000); wait.Until(ExpectedConditions.ElementExists(By.CssSelector("form[name='myForm']"))); ng_form_element = new NgWebElement(ngDriver, driver.FindElement(By.CssSelector("form[name='myForm']"))); ng_form_element.FindElement(NgBy.Model("amount")).SendKeys((account_balance - 10).ToString()); ng_form_element.FindElement(NgBy.ButtonText("Withdraw")).Click(); // inspect message ng_message = ngDriver.FindElement(NgBy.Binding("message")); StringAssert.Contains("Transaction successful", ng_message.Text); ngDriver.Highlight(ng_message, highlight_timeout); // re-read the amount int.TryParse(ngDriver.FindElement(NgBy.Binding("amount")).Text.FindMatch(@"(?<account_balance>\d+)$"), out updated_account_balance); Assert.AreEqual(10, updated_account_balance); }
public void Basic_AddOneAndTwo_ShouldBeThree() { ngDriver.Url = URL; var first = ngDriver.FindElement(NgBy.Input("first")); var second = ngDriver.FindElement(NgBy.Input("second")); var goButton = ngDriver.FindElement(By.Id("gobutton")); first.SendKeys("1"); second.SendKeys("2"); goButton.Click(); var latestResult = ngDriver.FindElement(NgBy.Binding("latest")).Text; latestResult.Should().Be("3"); }
public void PopulateValidControlSet(IWebDriver driverInstance) { IWebElement confidence = driverInstance.FindElement(By.Id("selConfidence")); IWebElement marginOfError = driverInstance.FindElement(By.Id("selMarginOfError")); IWebElement stratifyCheckbox = driverInstance.FindElement(By.Id("checkboxes-1")); IWebElement custodian = driverInstance.FindElement(By.Id("selCustodianFields")); IWebElement calculatedSize = driverInstance.FindElement(NgBy.Binding("ProjectWizardController.project.sampleSize")); IWebElement calculateBtn = driverInstance.FindElement(By.Id("calculateLimit")); confidence.FindElement(By.CssSelector("option[value='85']")).Click(); marginOfError.FindElement(By.CssSelector("option[value='3']")).Click(); stratifyCheckbox.Click(); calculateBtn.Click(); }
/// <summary> /// Here are the resrouces for this test method. /// - http://www.protractortest.org/#/tutorial /// - https://github.com/bbaia/protractor-net /// - https://anthonychu.ca/post/end-to-end-testing-angular-apps-with-nunit-and-specflow-using-protractornet/ /// /// </summary> public void Protractor_AddOneAndTwo_ShouldBeThree() { Trace.WriteLine("Test Started"); ngDriver.Url = "http://juliemr.github.io/protractor-demo/"; // navigate to URL ngDriver.FindElement(NgBy.Model("first")).SendKeys("1"); ngDriver.FindElement(NgBy.Model("second")).SendKeys("2"); ngDriver.FindElement(By.Id("gobutton")).Click(); var latestResult = ngDriver.FindElement(NgBy.Binding("latest")).Text; Trace.WriteLine("latestResult:" + latestResult); Trace.WriteLine("Test Ended"); }
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 OrganisationEditPage Edit(Organisation organisation) { foreach (var filterOrganisationField in this.OrganisationsField) { var nameElement = filterOrganisationField.FindElement(NgBy.Binding("organisation.Name")); if (nameElement.Text.Equals(organisation.Name)) { var editLink = filterOrganisationField.FindElement(By.LinkText("Edit")); editLink.Click(); break; } } return(this); }
public void SearchText() { IWebElement searchbox = ngdriver.FindElement(By.ClassName("input--search")); searchbox.Click(); searchbox.SendKeys("New York, NY"); searchbox.SendKeys(Keys.Tab); searchbox.SendKeys(Keys.Enter); Thread.Sleep(10000); NgWebElement ng_account_number_element = ngdriver.FindElement(NgBy.Binding("location.label")); Assert.Equals("New York, NY", ng_account_number_element.Text.ToString()); }
public void ShouldFindAllBindings() { Common.GetLocalHostPageContent("ng_directive_binding.htm"); IWebElement container = ngDriver.FindElement(By.CssSelector("body div")); Console.Error.WriteLine(container.GetAttribute("innerHTML")); ReadOnlyCollection <NgWebElement> elements = ngDriver.FindElements(NgBy.Binding("name")); Assert.AreEqual(5, elements.Count); foreach (NgWebElement element in elements) { Console.Error.WriteLine(element.GetAttribute("outerHTML")); Console.Error.WriteLine(String.Format("Identity: {0}", element.IdentityOf())); Console.Error.WriteLine(String.Format("Text: {0}", element.Text)); } }
public void SimpleTMDBSearchTest() //FREQUENT TIME OUT EXCEPTION BECAUSE OF SLOW WEB API LOADING { MoviesRepository repo = new MoviesRepository(); repo.ClearCache(); var webdriver = new ChromeDriver(); webdriver.Manage().Timeouts().AsynchronousJavaScript = new System.TimeSpan(TimeOut); var ngDriver = new NgWebDriver(webdriver); ngDriver.Url = BaseUrl; ngDriver.Manage().Window.Maximize(); SelectElement selectBox = new SelectElement(ngDriver.FindElement(By.Id("selectDataSource"))); foreach (var op in selectBox.Options) { if (op.Text == "TMDB") { op.Click(); break; } } ngDriver.FindElement(NgBy.Model("dtFrom")).Clear(); ngDriver.FindElement(NgBy.Model("dtFrom")).SendKeys("2000"); ngDriver.FindElement(NgBy.Model("dtTo")).Clear(); ngDriver.FindElement(NgBy.Model("dtTo")).SendKeys("2017"); ngDriver.FindElement(By.Id("inputSearchMovies")).SendKeys("007"); ngDriver.FindElement(By.Id("btnSearch")).Click(); try { var title = ngDriver.FindElement(NgBy.Binding("movie.Title"))?.Text; Assert.IsTrue(!string.IsNullOrEmpty(title)); } catch (Exception) { Assert.Fail(); } finally { webdriver.Close(); } }
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 ShouldPrintOrderByFieldColumn() { GetPageContent("ng_headers_sort_example2.htm"); String[] headers = new String[] { "First Name", "Last Name", "Age" }; foreach (String header in headers) { for (int cnt = 0; cnt != 2; cnt++) { IWebElement headerElement = ngDriver.FindElement(By.XPath("//th/a[contains(text(),'" + header + "')]")); Console.Error.WriteLine("Clicking on header: " + header); headerElement.Click(); // triggers ngDriver.WaitForAngular() Assert.IsNotEmpty(ngDriver.Url); ReadOnlyCollection <NgWebElement> ng_emps = ngDriver.FindElements(NgBy.Repeater("emp in data.employees")); NgWebElement ng_emp = ng_emps[0]; String field = ng_emp.GetAttribute("ng-order-by"); Console.Error.WriteLine(field + ": " + ng_emp.Evaluate(field).ToString()); String empField = "emp." + ng_emp.Evaluate(field); Console.Error.WriteLine(empField + ":"); var ng_emp_enumerator = ng_emps.GetEnumerator(); ng_emp_enumerator.Reset(); while (ng_emp_enumerator.MoveNext()) { ng_emp = (NgWebElement)ng_emp_enumerator.Current; if (ng_emp.Text == null) { break; } Assert.IsNotNull(ng_emp.WrappedElement); // Console.Error.WriteLine(ngEmp.getAttribute("innerHTML")); try { NgWebElement ng_column = ng_emp.FindElement(NgBy.Binding(empField)); Assert.IsNotNull(ng_column); Console.Error.WriteLine(ng_column.Text); } catch (Exception ex) { Console.Error.WriteLine(ex.ToString()); } } } } }
public void SimpleIntegratedSearchTest() { MoviesRepository repo = new MoviesRepository(); repo.ClearCache(); var webdriver = new ChromeDriver(); webdriver.Manage().Timeouts().AsynchronousJavaScript = new System.TimeSpan(TimeOut); var ngDriver = new NgWebDriver(webdriver); ngDriver.Url = BaseUrl; ngDriver.Manage().Window.Maximize(); SelectElement selectBox = new SelectElement(ngDriver.FindElement(By.Id("selectDataSource"))); foreach (var op in selectBox.Options) { if (op.Text == "Integrated") { op.Click(); break; } } ngDriver.FindElement(NgBy.Model("dtFrom")).Clear(); ngDriver.FindElement(NgBy.Model("dtFrom")).SendKeys("2000"); ngDriver.FindElement(NgBy.Model("dtTo")).Clear(); ngDriver.FindElement(NgBy.Model("dtTo")).SendKeys("2016"); ngDriver.FindElement(By.Id("inputSearchMovies")).SendKeys("terminator 2"); ngDriver.FindElement(By.Id("inputSearchActor")).SendKeys("arnold"); ngDriver.FindElement(By.Id("btnSearch")).Click(); try { var title = ngDriver.FindElement(NgBy.Binding("movie.Title"))?.Text; Assert.IsTrue(!string.IsNullOrEmpty(title)); } catch (Exception) { Assert.Fail(); } }
public void ShouldFindElementByRepeaterColumn() { Common.GetLocalHostPageContent("ng_service.htm"); // TODO: properly wait for Angular service to complete Thread.Sleep(3000); // wait.Until(ExpectedConditions.ElementIsVisible(NgBy.Repeater("person in people"))); ReadOnlyCollection <NgWebElement> ng_people = ngDriver.FindElements(NgBy.Repeater("person in people")); if (ng_people.Count > 0) { ng_people = ngDriver.FindElements(NgBy.Repeater("person in people")); var check = ng_people.Select(o => o.FindElement(NgBy.Binding("person.Country"))); Assert.AreEqual(ng_people.Count, check.Count()); ReadOnlyCollection <NgWebElement> ng_countries = ngDriver.FindElements(NgBy.RepeaterColumn("person in people", "person.Country")); Assert.AreEqual(3, ng_countries.Count(o => String.Compare("Mexico", o.Text, StringComparison.InvariantCulture) == 0)); } }
public void ShouldSearchCitySuggestions() { String city = "Jacksonville, FL"; wait.Until(ExpectedConditions.ElementIsVisible(NgBy.Model("term"))); IWebElement search = driver.FindElement(By.XPath("//input[@name='search']")); Assert.IsNotNull(search); ngDriver.Highlight(search); // NOTE: Chrome is occasionally dropping first letter . // search.SendKeys(city[0].ToString()); // TODO: http://stackoverflow.com/questions/1450774/splitting-a-string-into-chunks-of-a-certain-size foreach (char cityChar in city.ToCharArray()) { Console.Error.WriteLine("Sending: {0}", cityChar); search.SendKeys(cityChar.ToString()); Thread.Sleep(50); } search.Click(); ReadOnlyCollection <NgWebElement> ng_elements = ngDriver.FindElements(NgBy.Repeater("item in results | limitTo:10")); foreach (NgWebElement ng_element in ng_elements) { try { Assert.IsNotNull(ng_element.FindElement(NgBy.Binding("getPresName($index)"))); Console.Error.WriteLine("Suggested: {0}", ng_element.Text); } catch (StaleElementReferenceException e) { Console.Error.WriteLine("Ignored exception: {0}", e.Message); } } NgWebElement ng_firstMatchingElement = ng_elements.First(x => x.Text.ToLower() == city.ToLower()); Assert.IsNotNull(ng_firstMatchingElement); ngDriver.Highlight(ng_firstMatchingElement); Console.Error.WriteLine("Clicking: {0}", ng_firstMatchingElement.Text); ng_firstMatchingElement.Click(); Thread.Sleep(1000); // TODO: Assert the change of the URL }
public void PerformNgByModelAction() { driver.Navigate().GoToUrl(base_url); ngDriver.Url = driver.Url; ngDriver.FindElement(By.CssSelector("[ng-click='customer()']")).Click(); ReadOnlyCollection <NgWebElement> ng_customers = ngDriver.FindElements(NgBy.Repeater("cust in Customers")); for (int iCust = 0; iCust < ng_customers.Count; iCust++) { ng_customers[3].Click(); } ngDriver.FindElement(By.CssSelector("[type='submit']")).Click(); ngDriver.WaitForAngular(); ReadOnlyCollection <NgWebElement> ng_accounts = ngDriver.FindElements(NgBy.Model("accountNo")); int iaccounts = ng_accounts.Count; var selectedaccount = ngDriver.FindElement(NgBy.Binding("accountNo")); var selectedaccountno = selectedaccount.Text; ngDriver.WaitForAngular(); }
public void PRC_CreateProject_NewProjectCreated_ShouldDisplayProjectInProjectList() { projectWizard.GoToProjectListPage(browser); projectWizard.ClickNewProjectButton(browser); projectWizard.PopulateValidProjectSettings(browser); projectWizard.ProjectSettingsClickNext(browser); projectWizard.PopulateValidControlSet(browser); projectWizard.ControlSetClickNext(browser); projectWizard.PopulateValidExampleSet(browser); projectWizard.ExamplesClickNext(browser); IWebElement projectName = browser.FindElement(NgBy.Binding("ProjectWizardController.project.name")); projectName.Text.Should().Be("TestProject"); projectWizard.SummaryClickFinish(browser); IWebElement grid = browser.FindElement(By.CssSelector(".k-grid")); grid.FindElement(By.XPath(".//span[text()='Case2']")).Should().NotBeNull(); }
public void ShouldFindOrderByField() { GetPageContent("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()); } ReadOnlyCollection <NgWebElement> ng_people = ngDriver.FindElements(NgBy.Repeater("person in people")); var ng_people_enumerator = ng_people.GetEnumerator(); ng_people_enumerator.Reset(); while (ng_people_enumerator.MoveNext()) { NgWebElement ng_person = (NgWebElement)ng_people_enumerator.Current; if (ng_person.Text == null) { break; } NgWebElement ng_name = ng_person.FindElement(NgBy.Binding("person.Name")); Assert.IsNotNull(ng_name.WrappedElement); Object obj_country = ng_person.Evaluate("person.Country"); Assert.IsNotNull(obj_country); if (String.Compare("Around the Horn", ng_name.Text) == 0) { StringAssert.IsMatch("UK", obj_country.ToString()); } } }
public void NameUpdate_UpdatesName() { String newPollName = "Poll Name Updated"; _driver.Navigate().GoToUrl(PollUrl); IWebElement manageNameSection = _driver.FindElement(By.Id("manage-name-section")); IWebElement editLink = manageNameSection.FindElement(By.Id("edit-link")); editLink.Click(); IWebElement editInput = manageNameSection.FindElements(By.TagName("Input")).Single(); editInput.Clear(); editInput.SendKeys(newPollName); manageNameSection.FindElement(By.TagName("Form")).Submit(); IWebElement pollName = manageNameSection.FindElement(NgBy.Binding("Question")); Assert.IsTrue(pollName.IsVisible()); Assert.AreEqual(newPollName, pollName.Text); }
public void Save_SavesChanges() { _driver.Navigate().GoToUrl(PollUrl); IWebElement addChoiceButton = _driver.FindElement(By.PartialLinkText("New Choice")); addChoiceButton.Click(); string newChoiceName = "Test Name"; string newChoiceDescription = "Test Description"; IWebElement formName = _driver.FindElement(NgBy.Model("addChoiceForm.name")); formName.SendKeys(newChoiceName); IWebElement formDescription = _driver.FindElement(NgBy.Model("addChoiceForm.description")); formDescription.SendKeys(newChoiceDescription); IWebElement addAnotherCheckbox = _driver.FindElement(By.Id("add-another-checkbox")); addAnotherCheckbox.Click(); IWebElement addButton = _driver.FindElement(By.Id("add-button")); addButton.Click(); Thread.Sleep(DialogClearWaitTime); IReadOnlyCollection <IWebElement> choices = _driver.FindElements(NgBy.Repeater("choice in choices")); IWebElement lastChoice = choices.Last(); IWebElement lastChoiceName = lastChoice.FindElement(NgBy.Binding("choice.Name")); IWebElement lastChoiceDescription = lastChoice.FindElement(NgBy.Binding("choice.Description")); Assert.AreEqual(newChoiceName, lastChoiceName.Text); Assert.AreEqual(newChoiceDescription, lastChoiceDescription.Text); }
public void ShouldSubstract() { #pragma warning disable 618 var first = ngDriver.FindElement(NgBy.Input("first")); #pragma warning restore 618 first.SendKeys("10"); #pragma warning disable 618 var second = ngDriver.FindElement(NgBy.Input("second")); #pragma warning restore 618 second.SendKeys("2"); ReadOnlyCollection <NgWebElement> ng_math_operators = ngDriver.FindElements(NgBy.Options("value for (key, value) in operators")); NgWebElement ng_substract_math_operator = ng_math_operators.First(op => op.Text.Equals("-", StringComparison.Ordinal)); Assert.IsNotNull(ng_substract_math_operator); ng_substract_math_operator.Click(); var goButton = ngDriver.FindElement(By.Id("gobutton")); goButton.Click(); NgWebElement result_element = ngDriver.FindElement(NgBy.Binding("latest")); Assert.AreEqual("8", result_element.Text); ngDriver.Highlight(result_element, 1000); }
public void ShouldInviteToOpenAccount() { // When I proceed to "Bank Manager Login" ngDriver.FindElement(NgBy.ButtonText("Bank Manager Login")).Click(); // And I proceed to "Add Customer" ngDriver.FindElement(NgBy.PartialButtonText("Add Customer")).Click(); // And I fill new Customer data IWebElement ng_first_name = ngDriver.FindElement(NgBy.Model("fName")); ngDriver.Highlight(ng_first_name, highlight_timeout); StringAssert.IsMatch("First Name", ng_first_name.GetAttribute("placeholder")); ng_first_name.SendKeys("John"); IWebElement ng_last_name = ngDriver.FindElement(NgBy.Model("lName")); ngDriver.Highlight(ng_last_name, highlight_timeout); StringAssert.IsMatch("Last Name", ng_last_name.GetAttribute("placeholder")); ng_last_name.SendKeys("Doe"); IWebElement ng_post_code = ngDriver.FindElement(NgBy.Model("postCd")); ngDriver.Highlight(ng_post_code, highlight_timeout); StringAssert.IsMatch("Post Code", ng_post_code.GetAttribute("placeholder")); ng_post_code.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, highlight_timeout); ng_add_customer_button.Submit(); // confirm string alert_text = null; try { alert = ngDriver.WrappedDriver.SwitchTo().Alert(); alert_text = alert.Text; StringAssert.StartsWith("Customer added successfully with customer id :", alert_text); alert.Accept(); } catch (NoAlertPresentException ex) { // Alert not present verificationErrors.Append(ex.StackTrace); } catch (WebDriverException ex) { // Alert not handled by PhantomJS verificationErrors.Append(ex.StackTrace); } int customer_id = 0; int.TryParse(alert_text.FindMatch(@"(?<customer_id>\d+)$"), out customer_id); Assert.AreNotEqual(0, customer_id); // And I switch to "Home" screen ngDriver.FindElement(NgBy.ButtonText("Home")).Click(); // And I proceed to "Customer Login" ngDriver.FindElement(NgBy.ButtonText("Customer Login")).Click(); // And I login as new customer "John Doe" ReadOnlyCollection <NgWebElement> ng_customers = ngDriver.FindElements(NgBy.Repeater("cust in Customers")); int customer_count = ng_customers.Count; NgWebElement ng_new_customer = ng_customers.First(cust => Regex.IsMatch(cust.Text, "John Doe")); Assert.IsNotNull(ng_new_customer); actions.MoveToElement(ng_new_customer.WrappedElement).Build().Perform(); ngDriver.Highlight(ng_new_customer, highlight_timeout); ng_new_customer.Click(); NgWebElement ng_login_button = ngDriver.FindElement(NgBy.ButtonText("Login")); Assert.IsTrue(ng_login_button.Displayed && ng_login_button.Enabled); ngDriver.Highlight(ng_login_button, highlight_timeout); ng_login_button.Click(); // Then I am greeted as "John Doe" NgWebElement ng_user = ngDriver.FindElement(NgBy.Binding("user")); StringAssert.Contains("John", ng_user.Text); StringAssert.Contains("Doe", ng_user.Text); // And I am invited to open an account Object noAccount = ng_user.Evaluate("noAccount"); Assert.IsTrue(Boolean.Parse(noAccount.ToString())); Boolean hasAccounts = !(Boolean.Parse(noAccount.ToString())); Console.Error.WriteLine("Has accounts: " + hasAccounts); // IWebElement invitationMessage = driver.FindElement(By.CssSelector("span[ng-show='noAccount']")); IWebElement invitationMessage = ng_user.FindElement(By.XPath("..")).FindElement(By.XPath("..")).FindElement(By.CssSelector("span[ng-show='noAccount']")); Assert.IsTrue(invitationMessage.Displayed); ngDriver.Highlight(invitationMessage); StringAssert.Contains("Please open an account with us", invitationMessage.Text); Console.Error.WriteLine(invitationMessage.Text); // And I have no accounts NgWebElement accountNo = ngDriver.FindElement(NgBy.Binding("accountNo")); Assert.IsFalse(accountNo.Displayed); ReadOnlyCollection <NgWebElement> ng_accounts = ngDriver.FindElements(NgBy.Repeater("account for account in Accounts")); Assert.AreEqual(0, ng_accounts.Count); }