/// <summary> /// Searches for product. /// </summary> /// <param name="productName">Name of the product.</param> public virtual void SearchForProduct(string productName) { var currentWindowHandle = WrappedDriver.CurrentWindowHandle; ProductNameElement.SetValue(productName); SearchElement.Click(); WrappedDriver .Wait(TimeSpan.FromSeconds(2)) .Until(d => !ProductsGrid.IsBusy()); var firstCheckbox = ProductsGrid .GetCell(0, 0) .FindElement(By.TagName("input")); var checkbox = new CheckboxElement(firstCheckbox); checkbox.Check(true); SaveElement.Click(); // Wait for the page to close. WrappedDriver .Wait(TimeSpan.FromSeconds(10)) .Until(d => !d.WindowHandles.Contains(currentWindowHandle)); }
/// <summary> /// Searches using the search model. /// </summary> /// <param name="searchModel">The search model.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">searchModel</exception> public virtual IListPage Search(CustomerSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } EmailElement.SetValue(searchModel.Email); FirstNameElement.SetValue(searchModel.FirstName); LastNameElement.SetValue(searchModel.LastName); if (searchModel.DateOfBirth.HasValue) { DateOfBirthMonthElement.SelectByValue( searchModel.DateOfBirth.Value.Month.ToString()); DateOfBirthDayElement.SelectByValue( searchModel.DateOfBirth.Value.Day.ToString()); } else { DateOfBirthMonthElement.SelectByIndex(0); DateOfBirthDayElement.SelectByIndex(0); } CompanyElement.SetValue(searchModel.Company); IpAddressElement.SetValue(searchModel.IpAddress); var currentlySelectedItems = CustomerRoles.GetSelectedOptions(); if (searchModel.CustomerRoles != null) { foreach (var opt in currentlySelectedItems) { if (!searchModel.CustomerRoles?.Contains(opt) ?? true) { CustomerRoles.DeselectItem(opt); } // Check if there are items that have yet to be selected. if (searchModel.CustomerRoles?.Except(currentlySelectedItems).Any() ?? false) { foreach (var _opt in searchModel.CustomerRoles) { CustomerRoles.SelectItem(_opt); } } } } SearchElement.Click(); // Wait for the ajax indicator to toggle. WrappedDriver .Wait(TimeSpan.FromSeconds(10)) .TrySequentialWait( out var exception, d => IsAjaxBusy(), d => !IsAjaxBusy()); // Page should reload. Load(); return(this); }