public void CarlaLoginWorker() { Random random = new Random(); string test_start = "bcservice/token/AT" + DateTime.Now.Ticks.ToString() + random.Next(0, 999).ToString(); ngDriver.Navigate().GoToUrl($"{baseUri}{test_start}"); ngDriver.WaitForAngular(); /* * Page Title: Terms of Use */ NgWebElement uiCheckBox1 = ngDriver.FindElement(By.XPath("//input[@type='checkbox']")); uiCheckBox1.Click(); NgWebElement uiCheckBox2 = ngDriver.FindElement(By.XPath("(//input[@type='checkbox'])[2]")); uiCheckBox2.Click(); NgWebElement continueButton = ngDriver.FindElement(By.CssSelector(".buttons .btn-primary")); continueButton.Click(); /* * Page Title: Please confirm the name belonging to the BC Services card you provided */ NgWebElement yesButton = ngDriver.FindElement(By.CssSelector("button.btn-primary")); yesButton.Click(); }
public NgWebElement GetElement(string elementID) { NgWebElement element = ngDriver.FindElement(By.Id(elementID)); Assert.IsNotNull(element, string.Format("ElementID : {0}", elementID)); return(element); }
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 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.Model("query")).SendKeys("bravo"); Assert.AreEqual(1, ngDriver.FindElements(NgBy.Repeater("phone in phones")).Count); ngDriver.FindElement(NgBy.Model("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 FirstTest() { driver.Navigate().GoToUrl(URL); ngDriver.WaitForAngular(); //Find product price text box using the ng-model NgWebElement ProductPrice = ngDriver.FindElement(NgBy.Model("productPrice")); ProductPrice.SendKeys(TestContext.DataRow["ProductPrice"].ToString()); Thread.Sleep(2000); //Find discount text box using the ng-model NgWebElement DiscountOnProduct = ngDriver.FindElement(NgBy.Model("discountPercent")); DiscountOnProduct.SendKeys(TestContext.DataRow["DiscountOnProduct"].ToString()); Thread.Sleep(2000); //Find button using selenium locator XPath NgWebElement BtnPriceAfterDiscount = ngDriver.FindElement(By.XPath("//*[@id='f1']/fieldset[2]/input[1]")); BtnPriceAfterDiscount.Click(); Thread.Sleep(2000); //Find discounted product text box using the ng-model NgWebElement afterDiscountValue = ngDriver.FindElement(NgBy.Model("afterDiscount")); string value = afterDiscountValue.GetAttribute("value"); Thread.Sleep(2000); //Assert for corect value Assert.AreEqual <string>(TestContext.DataRow["AfterDiscountPrice"].ToString(), value); }
/// <summary> /// Helper function to populate the Local Government / Indigenous Nation and Police Jurisdiction fields. /// This function is centralized as the same code is used on all application types. /// Past issues that have been attempted to be resolved with this code include the item being found but not clicked on /// properly. /// </summary> /// <param name="lgin">Name of the lgin. Defaults to "Parksville" in most cases</param> /// <param name="police">Name of the police jurisdiction</param> private void FillLginAndPolice(string lgin, string police) { // search for and select Parksville as the local government var uiIndigenousNation = ngDriver.FindElement(By.CssSelector("input[formcontrolname='indigenousNation']")); uiIndigenousNation.SendKeys(lgin); var uiIndigenousNation2 = FindFirstElementByCssWithRetry("span[class='mat-option-text']"); if (uiIndigenousNation2 != null) { JavaScriptClick(uiIndigenousNation2); } // search for and select Oceanside RCMP as the police jurisdiction var uiPoliceJurisdiction = ngDriver.FindElement(By.CssSelector("input[formcontrolname='policeJurisdiction']")); uiPoliceJurisdiction.SendKeys(police); var uiPoliceJurisdiction2 = FindFirstElementByCssWithRetry("span[class='mat-option-text']"); if (uiIndigenousNation2 != null) { JavaScriptClick(uiPoliceJurisdiction2); } }
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 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 ShouldGreetUsingBinding() { IWebDriver ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl(base_url ); ngDriver.FindElement(NgBy.Model("yourName")).SendKeys("Julie"); Assert.AreEqual("Hello Julie!", ngDriver.FindElement(NgBy.Binding("yourName")).Text); }
public void ShouldGreetUsingBinding() { var ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl(base_url); ngDriver.FindElement(NgBy.Model("yourName")).SendKeys("Julie"); Assert.AreEqual("Hello Julie!", ngDriver.FindElement(NgBy.Binding("yourName")).Text); }
public TutorialStep5Page SearchFor(string query) { var q = ngDriver.FindElement(NgBy.Input("query")); q.Clear(); q.SendKeys(query); return(this); }
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 checkname() { ngdriver.WaitForAngular(); NgWebElement profilename = ngdriver.FindElement(By.CssSelector("#DeltaPlaceHolderMain > app-intry > app-header > div > div > div.pull-right > div > span")); String name = profilename.GetAttribute("innerText"); Console.WriteLine(name); Assert.AreEqual(name, "Ivan Lesnikov"); }
public void GetNgDropDown(string ngModelname, By drpdwlist, By txtBox) { NgWebElement element = ngDriver.FindElement(NgByModel.Name(ngModelname)); string text = element.Text.Replace("\r\n", ","); string[] items = text.Split(','); _driver.FindElement(drpdwlist).Click(); _driver.FindElement(txtBox).SendKeys(items[1] + Keys.Enter); }
public ReviewPage(string url, NgWebDriver driver) { this.url = url; this.driver = driver; driver.Url = url; Entities = driver.FindElements(By.ClassName("inline-edit")).Select(i => new Entity(i)).ToList(); docTextContainer = driver.FindElement(By.ClassName("doc-text_container")); fullText = driver.FindElement(By.Id("full-text")); }
public void CardViewByDefault() { IWebDriver ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); // Assert 'card view' is selected Assert.IsTrue(ngDriver.FindElement(By.ClassName("cardContainer")).Displayed); Assert.IsFalse(ngDriver.FindElement(By.ClassName("gridContainer")).Displayed); }
public LoginPage(string url, NgWebDriver driver) { this.url = url; this.driver = driver; driver.Url = url; emailField = driver.FindElement(By.Id("email")); passwordField = driver.FindElement(By.Id("password")); loginButton = driver.FindElement(By.TagName("button")); }
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 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"); }
/// <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 CustomersPage(NgWebDriver driver) { ngDriver = driver; if (!ngDriver.Url.EndsWith("#/customers")) { throw new InvalidOperationException("This is not the customers page"); } cardViewButtonElement = ngDriver.FindElement(By.XPath("//ul[@class='nav']//li[contains(.,'Card View')]")); cardViewElement = ngDriver.FindElement(By.ClassName("cardContainer")); listViewButtonElement = ngDriver.FindElement(By.XPath("//ul[@class='nav']//li[contains(.,'List View')]")); listViewElement = ngDriver.FindElement(By.ClassName("gridContainer")); }
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 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 SwitchToListView() { IWebDriver ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); IWebElement listViewMenu = ngDriver.FindElement(By.XPath("//ul//li[contains(.,'List View')]")); Assert.IsFalse(listViewMenu.GetAttribute("class").Contains("active")); listViewMenu.Click(); // Assert 'list view' is selected Assert.IsTrue(listViewMenu.GetAttribute("class").Contains("active")); Assert.IsFalse(ngDriver.FindElement(By.ClassName("cardContainer")).Displayed); Assert.IsTrue(ngDriver.FindElement(By.ClassName("gridContainer")).Displayed); }
public void GivenUserFillesTheFieldsWithForRegistration() { ngDriver = new NgWebDriver(driver); _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); /*ReadOnlyCollection<NgWebElement>*/ var firstName = ngDriver.FindElement(NgBy.Model("FirstName")); //NgWebElement firstName = ngDriver.FindElement(By.TagName("FirstName")); firstName.SendKeys("hello"); //input = wd.findElement(By.tagName("input")); //System.out.println("fieldValue=" + input.getAttribute("value")); _driver.Quit(); //wd.get("http://jsfiddle.net/SAWsA/11/show/"); //NgWebElement input = ngDriver.FindElement(By.Name("name='FirstName'")); //input = wd.findElement(By.tagName("input")); //System.out.println("fieldValue=" + input.getAttribute("value")); ngDriver.Quit(); //_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); //var firstName = _driver.FindElement(By.CssSelector("input[ng-model='FirstName']")); firstName.SendKeys("GenRandomString()"); }
public void TestAjApps() { ngWebDriver.Navigate().GoToUrl("https://hello-angularjs.appspot.com/sorttablecolumn"); NgWebElement element = ngWebDriver.FindElement(NgBy.Model("searchKeyword")); element.SendKeys("Angular"); }
public void HelloNgDriver() { NgWebElement ngElement = _ngWebDriver.FindElement(NgBy.Model("q")); ngElement.Clear(); ngElement.SendKeys("Hello NgWebDriver"); }
public void ShouldWaitForAngular() { ngDriver.Navigate().GoToUrl(base_url); IWebElement element = ngDriver.FindElement(NgBy.Model("yourName")); Assert.IsTrue(((NgWebElement)element).Displayed); }
public void Angular2Test() { var ngDriver = new NgWebDriver(driver); ngDriver.Navigate().GoToUrl("https://material.angular.io/"); ngDriver.FindElement(By.XPath("//a[@routerlink='/guide/getting-started']")).Click(); Assert.AreEqual("https://material.angular.io/guide/getting-started", ngDriver.Url); }
public void TestMethod1() { ngdriver.Url = URL; ngdriver.WaitForAngular(); //Find product price text box using the ng-model NgWebElement ProductPrice = ngdriver.FindElement(NgBy.Model("productPrice")); ProductPrice.SendKeys("799"); Thread.Sleep(2000); //Find discount text box using the ng-model NgWebElement DiscountOnProduct = ngdriver.FindElement(NgBy.Model("discountPercent")); DiscountOnProduct.SendKeys("10"); Thread.Sleep(2000); //Find button using selenium locator XPath NgWebElement BtnPriceAfterDiscount = ngdriver.FindElement(By.XPath("//*[@id='f1']/fieldset[2]/input[1]")); BtnPriceAfterDiscount.Click(); Thread.Sleep(2000); //Find discounted product text box using the ng-model NgWebElement afterDiscountValue = ngdriver.FindElement(NgBy.Model("afterDiscount")); string value = afterDiscountValue.GetAttribute("value"); Thread.Sleep(2000); //Assert for corect value Assert.AreEqual <string>("719.1", value); //Use if condition for custom checks if (value == "719.1") { //Do Nothing. } else { Assert.Fail(); } }
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(); }