/// <summary> /// Loads the component. Checks to see if the current url matches /// the Route and if not an exception is thrown. If the WrappedDriver /// is an <see cref="T:OpenQA.Selenium.Support.Events.EventFiringWebDriver" /> event listeners will be /// added to the <see cref="E:OpenQA.Selenium.Support.Events.EventFiringWebDriver.Navigated" /> event /// which will call <see cref="M:ApertureLabs.Selenium.PageObjects.PageObject.Dispose" /> on this instance. /// NOTE: /// If overriding don't forget to either call base.Load() or make sure /// the <see cref="P:ApertureLabs.Selenium.PageObjects.PageObject.Uri" /> and the <see cref="P:ApertureLabs.Selenium.PageObjects.PageObject.WindowHandle" /> are /// assigned to. /// </summary> /// <returns> /// A reference to this /// <see cref="T:OpenQA.Selenium.Support.UI.ILoadableComponent" />. /// </returns> public override ILoadableComponent Load() { base.Load(); basePage.Load(); Orders.Load(); StartDateComponent.Load(); EndDateComponent.Load(); OrderStatusesComponent.Load(); PaymentStatusesComponent.Load(); ShippingStatusesComponent.Load(); return(this); }
/// <summary> /// Adds the new tier price. /// </summary> /// <param name="tierPricingModel">The tier pricing model.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">tierPricingModel</exception> public virtual TierPricesComponent AddNewTierPrice( TierPriceModel tierPricingModel) { if (tierPricingModel == null) { throw new ArgumentNullException(nameof(tierPricingModel)); } var cachedWindowHandle = WrappedDriver.CurrentWindowHandle; var cachedWindowHandles = WrappedDriver.WindowHandles; AddNewTierPriceElement.Click(); WrappedDriver .Wait(TimeSpan.FromSeconds(10)) .Until(d => d.WindowHandles.Count > cachedWindowHandles.Count); // Switch to new window. var newHandle = WrappedDriver.WindowHandles .Except(cachedWindowHandles) .First(); WrappedDriver.SwitchTo().Frame(newHandle); // Load the StartDate/EndDate components. StartDateComponent.Load(); EndDateComponent.Load(); // Enter values. QuantityElement.SetValue(tierPricingModel.Quantity); PriceElement.SetValue(tierPricingModel.Price); StoreElement.SelectByText(tierPricingModel.Store); CustomerRoleElement.SelectByText(tierPricingModel.CustomerRole); StartDateComponent.SetValue(tierPricingModel.StartDate); EndDateComponent.SetValue(tierPricingModel.EndDate); // Save. var saveEl = SaveElement; // Cache this to avoid extra lookups. saveEl.Click(); WrappedDriver .Wait(TimeSpan.FromSeconds(10)) .Until(d => saveEl.IsStale()); // Switch back to the original handle. WrappedDriver.SwitchTo().Frame(cachedWindowHandle); return(this); }
/// <summary> /// Searches the specified order search model. /// </summary> /// <param name="orderSearchModel">The order search model.</param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public virtual IListPage Search(OrderSearchModel orderSearchModel) { StartDateComponent.SetValue(orderSearchModel.StartDate); EndDateComponent.SetValue(orderSearchModel.EndDate); ProductNameElement.SetValue(orderSearchModel.ProductName); OrderStatusesComponent.SelectOptions(orderSearchModel.OrderStatuses); PaymentStatusesComponent.SelectOptions(orderSearchModel.PaymentStatuses); ShippingStatusesComponent.SelectOptions(orderSearchModel.ShippingStatuses); if (!String.IsNullOrEmpty(orderSearchModel.StoreName)) { var storeIndex = StoreElement.Options.IndexOf( el => String.Equals( el.TextHelper().InnerText, orderSearchModel.StoreName, StringComparison.Ordinal)); if (storeIndex == -1) { throw new NoSuchElementException(); } StoreElement.SelectByIndex(storeIndex); } if (!String.IsNullOrEmpty(orderSearchModel.VendorName)) { var vendorIndex = StoreElement.Options.IndexOf( el => String.Equals( el.TextHelper().InnerText, orderSearchModel.VendorName, StringComparison.Ordinal)); if (vendorIndex == -1) { throw new NoSuchElementException(); } VendorElement.SelectByIndex(vendorIndex); } BillingPhoneNumberElement.SetValue(orderSearchModel.BillingPhone); BillingEmailAddressElement.SetValue(orderSearchModel.BillingEmail); BillingLastNameElement.SetValue(orderSearchModel.BillingLastName); if (!String.IsNullOrEmpty(orderSearchModel.BillingCountryName)) { var billingCountryIndex = BillingCountryElement.Options.IndexOf( el => String.Equals( el.TextHelper().InnerText, orderSearchModel.BillingCountryName, StringComparison.Ordinal)); if (billingCountryIndex == -1) { throw new NoSuchElementException(); } BillingCountryElement.SelectByIndex(billingCountryIndex); } if (!String.IsNullOrEmpty(orderSearchModel.PaymentMethodName)) { var paymentMethodIndex = PaymentMethodElement.Options.IndexOf( el => String.Equals( el.TextHelper().InnerText, orderSearchModel.PaymentMethodName, StringComparison.Ordinal)); if (paymentMethodIndex == -1) { throw new NoSuchElementException(); } PaymentMethodElement.SelectByIndex(paymentMethodIndex); } OrderNotesElement.SetValue(orderSearchModel.OrderNotes); return(this); }