public void HelloNgDriver() { NgWebElement ngElement = NgDriver.FindElement(NgBy.Model("q")); ngElement.Clear(); ngElement.SendKeys("Hello NgWebDriver"); }
/// <summary> /// Finds all <see cref="NgWebElement" />s within the current context /// using the given mechanism. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns> /// A <see cref="ReadOnlyCollection{T}" /> of all <see cref="NgWebElement" />s /// matching the current criteria, or an empty list if nothing matches. /// </returns> public ReadOnlyCollection <NgWebElement> FindElements(By by) { if (by is JavaScriptBy scriptBy) { scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement } } ; NgDriver.WaitForAngular(); return(new ReadOnlyCollection <NgWebElement>(WrappedElement.FindElements(by) .Select(e => new NgWebElement(NgDriver, e)).ToList())); } IWebElement ISearchContext.FindElement(By by) { return(FindElement(by)); } ReadOnlyCollection <IWebElement> ISearchContext.FindElements(By by) { if (by is JavaScriptBy scriptBy) { scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement } } ; NgDriver.WaitForAngular(); return(new ReadOnlyCollection <IWebElement>(WrappedElement.FindElements(by) .Select(e => (IWebElement) new NgWebElement(NgDriver, e)).ToList())); } #endregion } }
public ProjectPageBase() { NgDriver = DriverContext.NgDriver; NgDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(15); Mongo = DriverContext.Mongo; //Fiddler = DriverContext.Fiddler; }
public void HelloNgWrapperDriver() { NgDriver.Navigate().GoToUrl("https://material.angular.io/"); IWebElement element = NgDriver.WrappedDriver.FindElement(By.CssSelector("[ng-change='search(q)']")); element.Clear(); element.SendKeys("Hello Wrapper Driver"); }
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")); }
/// <summary> /// Approves the cert for IE if that's the browser that's being used /// </summary> private void ApproveCertificateForInternetExplorer() { if (BaseConfiguration.TestBrowser.Equals(BrowserType.InternetExplorer) && NgDriver.Title.Contains("Certificate")) { By by = By.Id("overridelink"); var element = new NgWebElement(NgDriver, NgDriver.FindElement(by), by); element.JavaScriptClick(); } }
public void NonAngularPageShouldBeSupported() { Assert.DoesNotThrow(() => { NgDriver.IgnoreSynchronization = true; NgDriver.Navigate().GoToUrl("http://www.google.com"); NgDriver.IgnoreSynchronization = false; }); }
/// <summary> /// Finds the first <see cref="NgWebElement" /> using the given mechanism. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns>The first matching <see cref="NgWebElement" /> on the current context.</returns> /// <exception cref="NoSuchElementException">If no element matches the criteria.</exception> public NgWebElement FindElement(By by) { if (by is JavaScriptBy scriptBy) { scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement } } ; NgDriver.WaitForAngular(); return(new NgWebElement(NgDriver, WrappedElement.FindElement(by))); }
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 BrowserAccept(bool isWrapped = false) { if (isWrapped) { NgDriver.WrappedDriver.SwitchTo().ActiveElement().SendKeys(Keys.Return); } else { NgDriver.SwitchTo().ActiveElement().SendKeys(Keys.Return); } }
public void TestModulo() { const string firstNumber = "5252"; const string secondNumber = "2525"; const string expectedResult = "202"; _calculatorPage.CalculateNumbers(firstNumber, secondNumber, MathematicalOperation.MODULO); NgDriver.WaitForAngular(); Assert.AreEqual(expectedResult, _calculatorPage.GetResult()); }
public void TestSubtraction() { const string firstNumber = "5252"; const string secondNumber = "2525"; const string expectedResult = "2727"; _calculatorPage.CalculateNumbers(firstNumber, secondNumber, MathematicalOperation.SUBTRACTION); NgDriver.WaitForAngular(); Assert.AreEqual(expectedResult, _calculatorPage.GetResult()); }
public void TestMultiplication() { const string firstNumber = "5252"; const string secondNumber = "2525"; const string expectedResult = "13261300"; _calculatorPage.CalculateNumbers(firstNumber, secondNumber, MathematicalOperation.MULTIPLICATION); NgDriver.WaitForAngular(); Assert.AreEqual(expectedResult, _calculatorPage.GetResult()); }
public bool CheckIfElementExists(By finder) { try { NgDriver.FindElement(finder); return(true); } catch { return(false); } }
/// <summary> /// Refreshes the current page. /// </summary> public void Refresh() { if (NgDriver.IgnoreSynchronization) { WrappedNavigation.Refresh(); } else { var url = NgDriver.ExecuteScript("return window.location.href;") as string; NgDriver.Url = url; } }
public bool SetElement(By by) { try { NgElement = new NgWebElement(NgDriver, NgDriver.FindElement(by), by); return(true); } catch { return(false); } }
/// <summary> /// Navigates to given url and measure time for this action including or not Ajax. /// </summary> /// <example>Sample confirmation for java script alert: <code> /// this.Driver.NavigateToAndMeasureTime("http://objectivity.co.uk", waitForAjax: true); /// </code></example> /// <param name="url">The URL.</param> /// <param name="waitForAjax">Wait or not for Ajax</param> public long NavigateToAndMeasureTime(Uri url, bool waitForAjax = false) { PerformanceHelper.Instance.StartMeasure(); NgDriver.Navigate().GoToUrl(url); if (waitForAjax) { WaitForAjax(); } PerformanceHelper.Instance.StopMeasure(); return(PerformanceHelper.Instance.GetLoadTimeList[PerformanceHelper.Instance.GetLoadTimeList.Count - 1].Duration); }
public void Deveria_deletar_Reserva_Voo_com_sucesso() { _flightPage.FlightReservationViewButton.Click(); _flightReservationPage = new FlightReservationPage(NgDriver); //action _flightReservationPage.FlightDeleteButton.Click(); Thread.Sleep(1000); NgDriver.SwitchTo().Alert().Accept(); //assert NgDriver.Url.Should().Contain("/flightReservation"); }
public void Deveria_deletar_Reserva_Hotel_com_sucesso() { _hotelPage.HotelReservationViewButton.Click(); _hotelReservationPage = new HotelReservationPage(NgDriver); //action _hotelReservationPage.HotelDeleteButton.Click(); Thread.Sleep(1000); NgDriver.SwitchTo().Alert().Accept(); //assert NgDriver.Url.Should().Contain("/hotelReservation"); }
public void Deveria_deletar_Reserva_Carro_com_sucesso() { _carPage.CarReservationViewButton.Click(); _carReservationPage = new CarReservationPage(NgDriver); //action _carReservationPage.CarDeleteButton.Click(); Thread.Sleep(1000); NgDriver.SwitchTo().Alert().Accept(); //assert NgDriver.Url.Should().Contain("/carReservation"); }
public bool SetElements(By by) { try { NgElements = new List <NgWebElement>(); foreach (var element in NgDriver.FindElements(by)) { NgElements.Add(new NgWebElement(NgDriver, element, by)); } return(true); } catch { return(false); } }
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 Deveria_Salvar_Reserva_Voo_com_sucesso() { //Arrange _flightPage.FlightReservationCreateButton.Click(); var command = FlightReservationRegisterCommandBuilder.Start().Build(); _flightReservationFormPage.FillData(command); //act _flightReservationFormPage.DefaultButtonsComponent.SaveButton.Click(); Thread.Sleep(1000); NgDriver.SwitchTo().Alert().Accept(); //assert NgDriver.Url.Should().Contain("/flights"); }
public void Deveria_editar_Reserva_Hotel_com_sucesso() { _hotelPage.HotelReservationViewButton.Click(); _hotelReservationPage = new HotelReservationPage(NgDriver); //action _hotelReservationPage.HotelReservationOpenButton.Click(); _hotelReservationFormPage.ClearData(); var command = HotelReservationRegisterCommandBuilder.Start().WithDescription("Atualizacao de reserva de voo").Build(); _hotelReservationFormPage.FillData(command); _hotelReservationFormPage.DefaultButtonsComponent.SaveButton.Click(); Thread.Sleep(1000); NgDriver.SwitchTo().Alert().Accept(); //assert NgDriver.Url.Should().Contain("/hotels"); }
public void Deveria_Salvar_Reserva_Hotel_com_sucesso() { //Arrange _hotelPage.HotelReservationCreateButton.Click(); var command = HotelReservationRegisterCommandBuilder.Start().Build(); _hotelReservationFormPage.FillData(command); //act _hotelReservationFormPage.DefaultButtonsComponent.SaveButton.Click(); Thread.Sleep(1000); NgDriver.SwitchTo().Alert().Accept(); //assert NgDriver.Url.Should().Contain("/hotels"); //_flightReservationPage.GenericGridComponent.HasAnyRow(2, command.Description).Should().BeTrue(); }
//Under the assumption that the BasePage is always created first for every test, this constructor is used to instantiate universal objects, // and execute universal logic (such as navigating to an app url), or even logging in. public BasePage(bool shouldNavigateToBaseUrl = true, LoginType loginType = LoginType.AnyUser) { LoginType = loginType; Value = new BsonDocumentValues(Mongo); SetEmailAddress(); Logger = LogManager.GetCurrentClassLogger(); Logger.Info("Tests being run on: " + BaseConfiguration.Base); SocialCredentials = new SocialCredentials(this); if (shouldNavigateToBaseUrl) { try { NgDriver.Navigate().GoToUrl(BaseConfiguration.GetUrlValue()); Thread.Sleep(1000); } catch { JSNavigate(); Thread.Sleep(1000); } } }
/// <summary> /// Move a single "item" forward in the browser's history. /// </summary> public void Forward() { NgDriver.WaitForAngular(); WrappedNavigation.Forward(); }
/// <summary> /// Move back a single entry in the browser's history. /// </summary> public void Back() { NgDriver.WaitForAngular(); WrappedNavigation.Back(); }
/// <summary> /// Evaluates the expression as if it were on the scope of the current element. /// </summary> /// <param name="expression">The expression to evaluate.</param> /// <returns>The expression evaluated by Angular.</returns> public object Evaluate(string expression) { NgDriver.WaitForAngular(); return(NgDriver.ExecuteScript(ClientSideScripts.Evaluate, WrappedElement, expression)); }
/// <summary> /// Submits this element to the web server. /// </summary> public void Submit() { NgDriver.WaitForAngular(); WrappedElement.Submit(); }