public static void CheckoutWithCartItemsVisa() { try { IJavaScriptExecutor js = ((IJavaScriptExecutor)Driver.WebDriver); WebDriverWait waitForElement = new WebDriverWait(Driver.WebDriver, TimeSpan.FromSeconds(30)); NavigationHeaderPageObjects nav = new NavigationHeaderPageObjects(); ChewablesPageObjects cpo = new ChewablesPageObjects(); //waitForElement.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(".m-icon-badge__counter"))); //nav.CheckoutButton.Click(); ////waitForElement.Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[.='Proceed to checkout']"))); //Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Your Cart")); //CartPageObjects cpo = new CartPageObjects(); //cpo.ProceedToCheckoutButton.Click(); waitForElement.Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[.='Checkout as guest']"))); Assert.IsTrue(Driver.WebDriver.PageSource.Contains("New to Juice Plus+?")); CheckoutPageObjects cop = new CheckoutPageObjects(); cop.CheckoutAsGuestButton.Click(); Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Billing Address")); Thread.Sleep(500); cop.FirstNameShippingTextbox.SendKeys(AddressInfo.ShippingAddress.FirstNameShipping.FirstName); cop.LastNameShippingTextbox.SendKeys(AddressInfo.ShippingAddress.LastNameShipping.LastName); cop.DaytimePhoneNumberShippingTextbox.SendKeys(AddressInfo.ShippingAddress.PrimaryPhoneShipping.PrimaryPhone); cop.AlternatePhoneNumberShippingTextbox.SendKeys(AddressInfo.ShippingAddress.AlternatePhoneShipping.AlternatePhone); cop.EmailShippingTextbox.SendKeys(AddressInfo.ShippingAddress.EmailShipping.Email); cop.StreetAddressDeliveryTextbox.SendKeys(AddressInfo.ShippingAddress.StreetAddShipping.StreetAdd); cop.OptionalStreetAddressDeliveryTextbox.SendKeys(AddressInfo.ShippingAddress.OptionalStreetShipping.OptionalStreet); cop.CityDeliveryTextbox.SendKeys(AddressInfo.ShippingAddress.CityShipping.City); cop.CountyDeliveryTextbox.SendKeys(AddressInfo.ShippingAddress.CountyShipping.County); js.ExecuteScript("arguments[0].click();", cop.ReferringRepNoRadioButton); /*js.ExecuteScript("arguments[0].click();", cop.ReferringRepYesRadioButton); * cop.ReferringRepNameIdTextbox.SendKeys("IR002626"); * //Actions action = new Actions(Driver.WebDriver); * //action.MoveToElement(cop.ReferringRepNameTextbox).Perform();*/ cpo.ScrollViewport(); /* waitForElement.Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[contains(.,'Martin Deegan')]"))); * Thread.Sleep(3000); * cop.ReferringRepNameTextbox.Click();*/ cop.ProceedToCheckoutButton.Click(); Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Secure Payment")); waitForElement.Until(ExpectedConditions.ElementIsVisible(By.Name("payment.cardNumber"))); Thread.Sleep(500); cop.PaymentCCNumberTextbox.SendKeys(CreditCardInfo.CreditCardNumber.VisaCCNum.ccnumberValid); cop.PaymentCCExpirationDateTextbox.SendKeys(CreditCardInfo.CCExpDate.VisaCCExpDate.VisaCCExpDateValid); cop.PaymentCVVTextbox.SendKeys(CreditCardInfo.CreditCardCCV.VisaCCV.VisaCCVValid); js.ExecuteScript("arguments[0].click();", cop.TOSAcceptCheckbox); js.ExecuteScript("arguments[0].click();", cop.ConfirmOrderButton); waitForElement.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(".m-checkout-confirmation__title"))); Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Thank you! Your order is confirmed.")); } catch (ArgumentException e) { Console.WriteLine(e); } }
public static void AddProductsToCart() { ChewablesPageObjects cpo = new ChewablesPageObjects(); ChewablesOrderPageObjects copo = new ChewablesOrderPageObjects(); NavigationActions.NavigateOurProductsChewablesClick(); Task.Delay(500).Wait(1500); cpo.ScrollViewport(); cpo.ShopNowPremiumChewables.Click(); Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Premium Soft Chewables")); cpo.ScrollViewport(); copo.AddToCartOrder.Click(); Thread.Sleep(1000); }
public static void AddBerryChewablesToCart() { WebDriverWait waitForElement = new WebDriverWait(Driver.WebDriver, TimeSpan.FromSeconds(30)); NavigationHeaderPageObjects nav = new NavigationHeaderPageObjects(); CapsulesPageObjects caps = new CapsulesPageObjects(); LandingPageObjects lan = new LandingPageObjects(); ChewablesPageObjects cpo = new ChewablesPageObjects(); ChewablesOrderPageObjects copo = new ChewablesOrderPageObjects(); CartPageObjects carp = new CartPageObjects(); try { NavigationActions.NavigateOurProductsChewablesClick(); try { Assert.IsFalse(Driver.WebDriver.PageSource.Contains("£")); // Assert.IsTrue(Driver.WebDriver.PageSource.Contains("€")); } catch (Exception e) { Console.WriteLine(e);; } Thread.Sleep(1000); lan.CookieAlertAcceptButton.Click(); Task.Delay(500).Wait(1500); cpo.ScrollViewport(); cpo.ShopNowBerryChewables.Click(); try { Assert.IsTrue(Driver.WebDriver.PageSource.Contains("Berry Chewables")); } catch (Exception e) { throw; } cpo.ScrollViewport(); var NumOfProducts = copo.NumOfProductOrder.GetAttribute("value"); try { Assert.That(NumOfProducts, Is.EqualTo("1")); } catch (Exception e) { Console.WriteLine(e);; } copo.IncrementArrowOrder.Click(); var incrProductCount = copo.NumOfProductOrder.GetAttribute("value"); Thread.Sleep(500); try { Assert.That(incrProductCount, Is.EqualTo("2")); } catch (Exception e) { Console.WriteLine(e);; } copo.DecrementArrowOrder.Click(); var decrProductCount = copo.NumOfProductOrder.GetAttribute("value"); try { Assert.That(decrProductCount, Is.EqualTo("1")); } catch (Exception e) { Console.WriteLine(e);; } copo.AddToCartOrder.Click(); Thread.Sleep(1000); var NumInCart = nav.CartIconCounter.Text; Console.WriteLine(NumInCart); Thread.Sleep(500); try { Assert.That(NumInCart, Is.EqualTo("1")); } catch (Exception e) { throw; } nav.CartIconCounter.Click(); } catch (ArgumentException e) { Console.WriteLine(e); } waitForElement.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(".m-icon-badge__counter"))); nav.CheckoutButton.Click(); carp.NavigateToProceedToCheckoutAndClick(); }