private async Task DoSearches(string userAgent) { var isMobile = userAgent == UserAgent.Mobile; using (var driver = await _driverFactory.GetDriver(userAgent)) { var loginTask = DoLogin(driver); var searchTermsTask = _searchTermProvider.GetTerms(); await Task.WhenAll(loginTask, searchTermsTask); Log.Info("Processing Searches"); var searchTerms = searchTermsTask.Result.ToList(); searchTerms.Shuffle(); var searchPage = BingSearchPage.NavigateTo(driver); searchPage = searchPage .EnsureLoggedIn() .AcceptCookies(); var maxSearches = isMobile ? 20 : 30; maxSearches += 15; // add some "padding" in case some searches don't register bool?isLevelOne = null; foreach (var searchTerm in searchTerms) { searchPage.Search(searchTerm); var tallyPage = RewardStatusPage.NavigateTo(driver); if (isLevelOne == null) { isLevelOne = tallyPage.IsLevelOne(); } bool complete; if (isLevelOne.Value) { complete = tallyPage.AllSearchComplete(); } else { complete = isMobile ? tallyPage.MobileSearchComplete() : tallyPage.PcSearchComplete(); } if (--maxSearches < 0 || complete) { Log.Info("Stopped searching"); break; } } driver.Close(); } }
public void BingSearchBye() { string query = "bye!"; driver.Navigate().GoToUrl(BingSearchPage.URL); BingSearchPage searchPage = new BingSearchPage(driver); BingResultPage resultPage = searchPage.search(query); Assert.IsTrue(resultPage.title.StartsWith(query), String.Format("Title: {0} does not start with query: {1}!", resultPage.title, query)); }
public void BingSearchHello() { //this code is repeated below intentionally. //Feel free to modify and experiment. string query = "hello!"; driver.Navigate().GoToUrl(BingSearchPage.URL); BingSearchPage searchPage = new BingSearchPage(driver); BingResultPage resultPage = searchPage.search(query); Assert.IsTrue(resultPage.title.StartsWith(query), String.Format("Title: {0} does not start with query: {1}!", resultPage.title, query)); }