public void ValidateMenuItems() { IndexPage indexPage = new IndexPage(Driver, Url); bool areMenuItemsPresent = indexPage.AreMenuItemsPresent(); Assert.IsTrue(areMenuItemsPresent, "Not all menu items are present."); WindowsPage windowsPage = indexPage.ClickOnWindowsMenuItem(); windowsPage.ClickOnWindows10Menu(); windowsPage.PrintAllWindowsDropDownOptions(); windowsPage.ClickOnSearchButton(); ProductOfferingPage productOfferingPage = windowsPage.SearchQuery("Visual studio"); productOfferingPage.PrintPriceTags(); float offeringPrice = productOfferingPage.GetPriceByIndex(0); ProductDetailsPage productDetailsPage = productOfferingPage.ClickOnPriceTagByIndex(0); float productDetailPrice = productDetailsPage.GetProductDetailPrice(); Assert.AreEqual(offeringPrice, productDetailPrice, "Offering price is not the same as detail price"); CartPage cartPage = productDetailsPage.ClickOnAddToCart(); int quantity = 20; cartPage.SetQuantityAmount(quantity); //Price assertions float totalPrice = cartPage.GetTotalPrice(); float cartPageSinglePrice = totalPrice / quantity; float expectedTotalPrice = offeringPrice * quantity; Assert.AreEqual(cartPageSinglePrice, productDetailPrice, offeringPrice, "Prices does not match."); Assert.AreEqual(totalPrice, expectedTotalPrice, "Total prices does not match"); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e) { base.OnElementChanged(e); if (_isShown) { return; } _isShown = true; if (Control == null) { var windowsPage = new WindowsPage(); var OAuth2Data = Xamarin.Forms.Application.Current.Properties["OAuth2Data"] as OAuth2RequestData; var auth = new OAuth2Authenticator( OAuth2Data.ClientId, OAuth2Data.Scope, new Uri(OAuth2Data.AuthorizeUrl), new Uri(OAuth2Data.RedirectUrl) ) { ClearCookiesBeforeLogin = true }; _frame = windowsPage.Frame; if (_frame == null) { _frame = new Frame(); windowsPage.Content = _frame; SetNativeControl(windowsPage); } auth.Completed += (sender, arg) => { if (arg.IsAuthenticated) { IocManager.Container.Resolve <IMessageBus>().Send(new OAuth2AccessTokenObtainedMessage { AccessToken = arg.Account.Properties["access_token"], Provider = OAuth2Data.Provider, }); } IocManager.Container.Resolve <IMessageBus>().Send(new OAuth2LoginPageClosed { Provider = OAuth2Data.Provider, }); }; auth.Error += (sender, arg) => { IocManager.Container.Resolve <IMessageBus>().Send(new OAuth2LoginPageClosed { Provider = OAuth2Data.Provider, }); }; var pageType = auth.GetUI(); _frame.Navigate(pageType, auth); Window.Current.Activate(); } }
public static void CloseMarketModal() { WindowsPage winPage = new WindowsPage(); if (winPage.closeTranslateModalButton.Displayed) { winPage.closeTranslateModalButton.Click(); } }
public void OneTimeSetUp() { p_home = new HomePage(web_driver); web_driver = p_home.DriverConn(); p_windows = new WindowsPage(web_driver); p_search = new SearchPage(web_driver); p_details = new DetailsPage(web_driver); p_cart = new CartPage(web_driver); }
public void Windows10MenuInWindowsPage() { var homePage = new HomePage(driver); homePage.GoToWindowsMenu(); var windowsPage = new WindowsPage(driver); windowsPage.Windows10MenuClick(); Assert.True(windowsPage.PrintAllWindows10DropdownList()); }
public static void Init(WindowsPage page) { MessagingCenter.Subscribe <StartLongRunningTask>(page, nameof(StartLongRunningTask), async(message) => { var access = await BackgroundExecutionManager.RequestAccessAsync(); switch (access) { case Unspecified: return; case AllowedMayUseActiveRealTimeConnectivity: return; case AllowedWithAlwaysOnRealTimeConnectivity: return; case Denied: return; } var task = new BackgroundTaskBuilder { Name = BackServiceName, //TaskEntryPoint = "Matcha.BackgroundService.UWP.MatchaBackgrounService" }; var trigger = new ApplicationTrigger(); task.SetTrigger(trigger); //var condition = new SystemCondition(SystemConditionType.InternetAvailable); task.Register(); await trigger.RequestAsync(); }); MessagingCenter.Subscribe <StopLongRunningTask>(page, nameof(StopLongRunningTask), message => { var tasks = BackgroundTaskRegistration.AllTasks; foreach (var task in tasks) { // You can check here for the name string name = task.Value.Name; if (name == BackServiceName) { task.Value.Unregister(true); } } //BackgroundAggregatorService.Instance.Stop(); }); }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); var auth = new OAuth2Authenticator( clientId: "207552723093297", // your OAuth2 client id scope: "public_profile,email", // the scopes for the particular API you're accessing, delimited by "+" symbols authorizeUrl: new Uri("https://graph.facebook.com/oauth/authorize"), // the auth URL for the service redirectUrl: new Uri("https://giveortakebackend.azurewebsites.net")); // the redirect URL for the service auth.Completed += async(sender, eventArgs) => { if (eventArgs.IsAuthenticated) { //App.SuccessfulLoginAction.Invoke(); // Use eventArgs.Account to do wonderful things Settings.FacebookAccessToken = eventArgs.Account.Properties["access_token"]; await GiveOrTake.FrontEnd.Shared.App.Current.MainPage.Navigation.PopModalAsync(); } else { // The user cancelled } }; WindowsPage windowsPage = new WindowsPage(); var _frame = windowsPage.Frame; if (_frame == null) { _frame = new Windows.UI.Xaml.Controls.Frame { Language = global::Windows.Globalization.ApplicationLanguages.Languages[0] }; windowsPage.Content = _frame; SetNativeControl(windowsPage); } Type pageType = auth.GetUI(); _frame.Navigate(pageType, auth); }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); if (showLogin && FacebookAuth.User == null) { showLogin = false; var loginPage = Element as ProviderLoginPage; string providername = loginPage.ProviderName; WindowsPage windowsPage = new WindowsPage(); var auth = GetAuthenticator(providername); _frame = windowsPage.Frame; if (_frame == null) { _frame = new Windows.UI.Xaml.Controls.Frame(); //_frame.Language = global::Windows.Globalization.ApplicationLanguages.Languages[0]; windowsPage.Content = _frame; SetNativeControl(windowsPage); } auth.Completed += async(sender, eventArgs) => { if (eventArgs.IsAuthenticated) { var request = GetRequest(providername); request.Account = eventArgs.Account; var fbResponse = await request.GetResponseAsync(); FacebookAuth.SetUser(providername, fbResponse.GetResponseText()); } else { // The user cancelled } }; _frame.Navigate(auth.GetUI(), auth); Window.Current.Activate(); } }
public void MicrosoftPage() { driver = new Driver("Chrome"); driver.Manage().Window.Maximize(); MicrosoftPage microsoftPage = new MicrosoftPage(driver); microsoftPage.Navigate(); Assert.IsTrue(microsoftPage.HasLanded()); OfficeProductsPage officeProductsPage = microsoftPage.OpenOfficeLink(); Assert.IsTrue(officeProductsPage.HasLanded()); microsoftPage.Navigate(); Assert.IsTrue(microsoftPage.HasLanded()); WindowsPage windowsPage = microsoftPage.OpenWindowsLink(); Assert.IsTrue(windowsPage.HasLanded()); }
public static void Init(WindowsPage page) { MessagingCenter.Subscribe<StartLongRunningTask>(page, nameof(StartLongRunningTask), async(message) => { var access = await BackgroundExecutionManager.RequestAccessAsync(); switch (access) { case Unspecified: return; case AllowedMayUseActiveRealTimeConnectivity: return; case AllowedWithAlwaysOnRealTimeConnectivity: return; case Denied: return; } var task = new BackgroundTaskBuilder { Name = "My Task", TaskEntryPoint = typeof(Matcha.BackgroundService.UWP.MatchaBackgrounService).ToString() }; var trigger = new ApplicationTrigger(); task.SetTrigger(trigger); //var condition = new SystemCondition(SystemConditionType.InternetAvailable); task.Register(); await trigger.RequestAsync(); }); MessagingCenter.Subscribe<StopLongRunningTask>(page, nameof(StopLongRunningTask), message => { }); }
protected override async void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e) { try { base.OnElementChanged(e); authenticator = ((AuthenticatorPage)base.Element).Authenticator; System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer.OnElementChanged"); if (e == null) { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: e = {null}"); } else { if (e.NewElement == null) { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: e.NewElement = {null}"); } if (e.OldElement == null) { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: e.OldElement = {null}"); } } if (Element == null) { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Element is {null}"); } else { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Element is " + Element); } if (Control == null) { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Control is {null}"); } else { System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Control is " + Control); } if (Control == null) { WindowsPage windowsPage = new WindowsPage(); frame = windowsPage.Frame; if (frame == null) { frame = new Windows.UI.Xaml.Controls.Frame { Language = global::Windows.Globalization.ApplicationLanguages.Languages[0] }; frame.NavigationFailed += Frame_NavigationFailed; frame.Navigated += Frame_Navigated; frame.Navigating += Frame_Navigating; frame.NavigationStopped += Frame_NavigationStopped; windowsPage.Content = frame; SetNativeControl(windowsPage); } authenticator.Completed -= Authenticator_Completed; authenticator.Completed += Authenticator_Completed; authenticator.Error -= Authenticator_Error; authenticator.Error += Authenticator_Error; Type pageType = authenticator.GetUI(); frame.Navigate(pageType, authenticator); Windows.UI.Xaml.Window.Current.Activate(); } } catch (Exception ex) { throw new Xamarin.Auth.AuthException("UWP OnElementChanged"); } return; }
public void InterviewTest(List <string> menuItems, string menuToNavigate, string menuToPrint, string searchValue, int elementsToPrint, int numberOfItems) { try { HomePage homePage = new HomePage(Driver, DriverWait); WindowsPage windowsPage = new WindowsPage(Driver, DriverWait); SearchResultsPage searchResultsPage = new SearchResultsPage(Driver, DriverWait); ProductDetailsPage productDetailsPage = new ProductDetailsPage(Driver, DriverWait); ShoppingCartPage shoppingCartPage = new ShoppingCartPage(Driver, DriverWait); string storedPrice; //Step 1. Go to https://www.microsoft.com/en-us/ homePage.NavigateTo(); //Step 2. Validate all menu items are present (Office - Windows - Surface - Xbox - Deals - Support) var menuNames = homePage.GetMenuNames(); Assert.AreEqual(menuItems, menuNames); //Step 3. Go to Windows homePage.ClickMenu(menuToNavigate); Assert.IsTrue(Driver.Url.ToUpper().Contains(menuToNavigate.ToUpper())); //Step 4. Once in Windows page, click on Windows 10 Menu windowsPage.ClickMenu(menuToPrint); //Step 5. Print all Elements in the dropdown var itemsToPrint = windowsPage.GetMenuDropDownList(); foreach (var item in itemsToPrint) { Console.WriteLine(item); } //Step 6. Go to Search next to the shopping cart windowsPage.ClickSearchButton(); //Step 7. Search for Visual Studio windowsPage.PerformSearch(searchValue); //Step 8. Print the price for the 3 first elements listed in Software result list searchResultsPage.ValidateStoreLanguage(); var priceList = searchResultsPage.GetPriceList(); if (priceList.Count < elementsToPrint) { Console.WriteLine("Not enough elements to print"); Assert.Fail(); } else { for (int i = 0; i < elementsToPrint; i++) { Console.WriteLine(priceList[i]); } } //Step 9. Store the price of the first one storedPrice = priceList.First(); //Step 10. Click on the first one to go to the details page searchResultsPage.ClickProductByPrice(storedPrice); //Step 11. Once in the details page, validate both prices are the same productDetailsPage.DenyNewsletter(); Assert.AreEqual(storedPrice, productDetailsPage.GetProductPrice()); //Step 12. Click Add To Cart productDetailsPage.ClickAddToCartButton(); //Step 13. Verify all 3 price amounts are the same var priceAmounts = shoppingCartPage.GetProductPriceList(); foreach (var price in priceAmounts) { Assert.AreEqual(storedPrice, price); } //Step 14. On the # of items dropdown select 20 and validate the Total amount is Unit Price * 20 shoppingCartPage.SetNumberOfItems(numberOfItems); var expectedTotalAmount = CurrencyConverter.FromCurrency(storedPrice) * numberOfItems; var actualTotalAmount = CurrencyConverter.FromCurrency(shoppingCartPage.GetProductGrossPrice()); Assert.AreEqual(expectedTotalAmount, actualTotalAmount); } catch (AssertionException ex) { Console.WriteLine($"Assertion Failed with message: {ex.Message}"); } catch (Exception ex) { Console.WriteLine($"Fatal error with message: {ex.Message}"); Assert.Fail(); } }
public static void TryEnterFullScreenMode(this WindowsPage page) { ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); }
public static void PressEnter() { WindowsPage winPage = new WindowsPage(); winPage.searchTextBox.SendKeys(Keys.Enter); }
public static void EnterSearchText(string textt) { WindowsPage winPage = new WindowsPage(); winPage.searchTextBox.SendKeys(textt); }
public static void SelectSearchButton() { WindowsPage winPage = new WindowsPage(); winPage.searchButton.Click(); }
public static void SelectWindows10() { WindowsPage winPage = new WindowsPage(); winPage.windows10Menu.Click(); }