private int CreateNewAddToCartMVT() { int mvtid = -1; VariationType testVariant = AddToCartButton.GetNextUntestedVariant(); if (testVariant != null) { mvtid = MVTHistory.CreateNewLiveMVT(TestTypesEnum.ADDTOCARTBUTTON); MVTHistory.AddNewTestVariantToMVT(mvtid, ref testVariant); } else { //Could not create new MVT as could not produce new test variant. if (AddToCartButton.IsAllVariationTested() == false) { //There are still untested variants. This must be an error. if (Configuration.IsDebugModeOn) { _CLI.Out("Error while trying to create new MVT.", true, false); } } return(-1); } return(mvtid); }
public void AddToCart(int quantity) { Quantity.Clear(); Quantity.SendKeys("" + quantity); AddToCartButton.Click(); Thread.Sleep(1000); }
private void EnterKeyPressedInComboBox(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { AddToCartButton.PerformClick(); } }
void ReleaseDesignerOutlets() { if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PhotoImage != null) { PhotoImage.Dispose(); PhotoImage = null; } if (AddToCartButton != null) { AddToCartButton.Dispose(); AddToCartButton = null; } if (CountField != null) { CountField.Dispose(); CountField = null; } }
private void EnterKeyPressedInPromoCode(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { if (PromoCodeText2.TextLength == 0 && AddToCartButton.Text == "Add to Cart") { DialogResult quick_question = MessageBox.Show("Did you mean to not apply a promocode?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (quick_question == DialogResult.Yes) { AddToCartButton.PerformClick(); } else { PromoCodeText2.Focus(); } } else { AddToCartButton.PerformClick(); } } }
private static void AddSpecificProducts(Products products) { List <string> ProductNames = GetProductNames(products); Actions actions = new Actions(Driver); IWebElement AddToCartButton; IWebElement ContinueShoppingButton; ReadOnlyCollection <IWebElement> PotentialProducts = Driver.FindElements(By.ClassName("product-container"), 5); foreach (IWebElement product in PotentialProducts) { if (!product.Displayed) { continue; } IWebElement NameElement = product.FindElement(By.ClassName("product-name")); if (ProductNames.Contains(NameElement.Text)) // Ideally, I'd compare a product SKU or UPC# to avoid changes to product names. { actions.MoveToElement(product); AddToCartButton = product.FindElement(By.CssSelector("[title=\"Add to cart\"]")); if (!AddToCartButton.Displayed) { continue; } actions.MoveToElement(AddToCartButton); Thread.Sleep(250); AddToCartButton.Click(); ContinueShoppingButton = Driver.FindElement(By.ClassName("continue"), 2, FindModifier.IS_VISIBLE); ContinueShoppingButton.Click(); } } }
private void CancelButton_Click(object sender, EventArgs e) { //Code which changes visisbilty of Form. QuantityValuesTextBox.Focus(); QuantityValuesTextBox.SelectAll(); AddToCartButton.Focus(); DataGridViewPanel.Visible = false; DataGridCart.Rows.Clear(); TotalCostValueTextBox.Clear(); // Local variable declaraion. int BeerNameIndexSelected = int.Parse(BeerNamesListBox.SelectedIndex.ToString()); int BeerSizeIndexSelected = int.Parse(BeerSubTypeListBox.SelectedIndex.ToString()); int QuantityEntered = int.Parse(QuantityValuesTextBox.Text); //Decison construct to check quantity is more than 0. if (QuantityEntered > 0) { //code to reduce the stock added while confirming. TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] = TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] + QuantityEntered; FinalValue = 0; DataGridCart.Rows.Clear(); QuantityValuesTextBox.Clear(); } //decison construct to check qunatity is less than 0. else if (QuantityEntered <= 0) { MessageBox.Show("Please input qunatity correctly", "Input quantity box", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void HandleAddToCartCTATags(WesofHtmlTag[] Tags, ref ServerResponse sRep) { //Check if the clients currently assigned MVT's are addtocart tests Variation[] relevantTestAssignments = MVTHistory.MatchLiveMVTWithTestType(sRep.Cookie.ModifiedMVTAssignments, TestTypesEnum.ADDTOCARTBUTTON); if (relevantTestAssignments != null) { //Todo, the client is already assigned to live AddToCartButton test(s) for (int i = 0; i < relevantTestAssignments.Length; i++) { relevantTestAssignments[i].ApplyModification(ref Tags, ref sRep); } return; } //Check if there is already a live mvt that experiments with the add to cart. int assignToMVTId = MVTHistory.GetSuitableLiveMVTforNewGUIDAssignment(TestTypesEnum.ADDTOCARTBUTTON); int assignToVariation; if (assignToMVTId == -1) { //No suitable live MVT found. Generate a new one. assignToMVTId = CreateNewAddToCartMVT(); } //Check if a test is available if (assignToMVTId > -1) { assignToVariation = AssignGuidToMVT(assignToMVTId, sRep.Cookie.Wesof_GUID, ref sRep); if (assignToVariation > -1) { Variation v = MVTHistory.GetVariant(assignToMVTId, assignToVariation); if (v != null) { v.ApplyModification(ref Tags, ref sRep); } else { if (Configuration.IsDebugModeOn) { _CLI.Out("Error. Expected variation object, returned null.", true, false); } } } } else { //Check if all the possible variations tested if (AddToCartButton.IsAllVariationTested()) { //Let's apply the winning variant. AddToCartButton.ApplyChangesBasedOnLatestWinner(ref Tags, ref sRep); } } _CLI.RefreshStatDashboard(); }
void ReleaseDesignerOutlets() { if (AddToCartButton != null) { AddToCartButton.Dispose(); AddToCartButton = null; } if (AmountText != null) { AmountText.Dispose(); AmountText = null; } if (bView != null) { bView.Dispose(); bView = null; } if (CancelButton != null) { CancelButton.Dispose(); CancelButton = null; } if (imgView != null) { imgView.Dispose(); imgView = null; } if (LongDescriptionText != null) { LongDescriptionText.Dispose(); LongDescriptionText = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PriceLabel != null) { PriceLabel.Dispose(); PriceLabel = null; } if (ShortDescriptionLabel != null) { ShortDescriptionLabel.Dispose(); ShortDescriptionLabel = null; } }
void ReleaseDesignerOutlets() { if (AddToCartButton != null) { AddToCartButton.Dispose(); AddToCartButton = null; } if (CancelButton != null) { CancelButton.Dispose(); CancelButton = null; } if (HotDogDetailView != null) { HotDogDetailView.Dispose(); HotDogDetailView = null; } if (HotDogImageView != null) { HotDogImageView.Dispose(); HotDogImageView = null; } if (LongDescriptionText != null) { LongDescriptionText.Dispose(); LongDescriptionText = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PriceLabel != null) { PriceLabel.Dispose(); PriceLabel = null; } if (QuantityInput != null) { QuantityInput.Dispose(); QuantityInput = null; } if (ShortDescriptionLabel != null) { ShortDescriptionLabel.Dispose(); ShortDescriptionLabel = null; } }
public void StartApplication() { Configuration.MainController = this; AddToCartButton.Initialise(); MVTHistory.SetCLI(ref _CLI); _CLI.ProgramStartWelcomeMessage(); _CLI.SetCurrentController(this); _CLI.WaitingForCommand(); }
//hover on search item and add to cart public void AddToCart() { Actions action = new Actions(PropertiesCollection.driver); action.MoveToElement(SearchResult).Perform(); AddToCartButton.Click(); //manage element not visible System.Threading.Thread.Sleep(5000); ProceedToCheckOutButton.Click(); }
private void AddToCartButtonModification(ref WesofHtmlTag[] tags, ref ServerResponse sRep) { foreach (WesofHtmlTag tag in tags) { AddToCartButtonVariation nButton = AddToCartButton.GetVariant((int)VariationType.id, ref tag.fullTagString); if (nButton != null) { sRep.ModifiedBody = sRep.ModifiedBody.Replace(nButton.UnModified, nButton.Modified); } } }
public Phone NavigateToCheckOut() { string currentPriceInCart = CurrentPrice.Text; IWebElement element = driver.FindElement(By.ClassName("wpsc_buy_button")); AddToCartButton.Click(); WebDriverWait wait = new WebDriverWait(driver, controlTimeOut); wait.Until((d) => driver.FindElement(notificationPopup).Displayed); CheckOutButton.Click(); DoPageTransition(); return(this); }
void ReleaseDesignerOutlets() { if (AddToCartButton != null) { AddToCartButton.Dispose(); AddToCartButton = null; } if (AmountText != null) { AmountText.Dispose(); AmountText = null; } if (CancelButton != null) { CancelButton.Dispose(); CancelButton = null; } if (DescriptionText != null) { DescriptionText.Dispose(); DescriptionText = null; } if (HotDogImageView != null) { HotDogImageView.Dispose(); HotDogImageView = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PriceLabel != null) { PriceLabel.Dispose(); PriceLabel = null; } if (ShortDescriptionLabel != null) { ShortDescriptionLabel.Dispose(); ShortDescriptionLabel = null; } }
public MultiVariateTest(int mvtid, TestTypesEnum tType) { id = mvtid; testType = tType; isActive = true; LaunchDateTime = DateTime.UtcNow; ResultType = TestResultType.Live; AssignedGuidsTotal = 0; Variation control = control = new Variation(0, true); if (tType == TestTypesEnum.ADDTOCARTBUTTON) { control.SetVariationType(AddToCartButton.GetCurrentWinnderControl()); } variants.Add(control); }
public void ValidateProductsChosen() { Helper.ScrollToSeeTheRightButton(_driver, FirstBlouse); FirstBlouse.Click(); _driver.SwitchTo().Frame(_driver.FindElement(By.XPath("//iframe[@src='http://automationpractice.com/index.php?id_product=2&controller=product&content_only=1']"))); FirstBlouseBigImage.Click(); Helper.ScrollToSeeTheRightButton(_driver, AddToCartButton); AddToCartButton.Click(); Thread.Sleep(2000); ContinueShoppingButton.Click(); Actions actions = new Actions(_driver); IWebElement target = DressesTab; actions.MoveToElement(target).Perform(); SummerDressesSubMenu.Click(); Helper.ScrollToSeeTheRightButton(_driver, ThirdDress); ThirdDress.Click(); _driver.SwitchTo().Frame(_driver.FindElement(By.XPath("//iframe[@src='http://automationpractice.com/index.php?id_product=7&controller=product&content_only=1']"))); ThirdDressBigImage.Click(); Helper.ScrollToSeeTheRightButton(_driver, AddToCartButton); AddToCartButton.Click(); Thread.Sleep(3000); ContinueShoppingButton.Click(); Helper.ScrollToSeeTheRightButton(_driver, TshirtsTab); TshirtsTab.Click(); Helper.ScrollToSeeTheRightButton(_driver, FirstTshirt); FirstTshirt.Click(); _driver.SwitchTo().Frame(_driver.FindElement(By.XPath("//iframe[@src='http://automationpractice.com/index.php?id_product=1&controller=product&content_only=1']"))); FirstTshirtBigImage.Click(); Helper.ScrollToSeeTheRightButton(_driver, AddToCartButton); AddToCartButton.Click(); Thread.Sleep(3000); CheckoutButton.Click(); Helper.ScrollToSeeTheRightButton(_driver, CartButton); CartButton.Click(); }
public ProductPage ClickAddToCartButton() { AddToCartButton.Click(); return(new ProductPage(driver)); }
/// <summary> /// Finalises a test that reached completion. /// </summary> private void FinishTest() { if (isActive == true) { CompletionDate = DateTime.Now; isActive = false; //Picking winning variant based on highest mean (and reached significance) //TODO, this implementation works only for A/B. For MVT (multi variants, a loop is needed //to select the most promising variant. //Did it reach significance if (Result.ReachedSignificance[0] == true) { //Is the control or the test variant has higher mean. int winnerVariantId = -1; if (Result.Means[0] > Result.Means[1]) { winnerVariantId = 0; ResultType = TestResultType.Negative; } else { winnerVariantId = 1; ResultType = TestResultType.Positive; } if (testType == TestTypesEnum.ADDTOCARTBUTTON) { //Set the new winner control variant. AddToCartButton.SetNewWinnerControl((int)variants[winnerVariantId].GetVariationType().id); } } else { //If test did not reach significance, then consider it abandonned. ResultType = TestResultType.Inconclusive; } /* * int highestmeanIndex = -1; * for (int i = 0; i < Result.ReachedSignificance.Length; i++) * { * * if(Result.ReachedSignificance[i] == true) * { * if(highestmeanIndex == -1) * { * highestmeanIndex = i; * } * else * { * //Is the test variant better than the control * if(Result.Means[0] > Result.Means[i+1]) * { * highestmeanIndex = i + 1; * } * } * } * * }*/ } }
public void ClickAddToCartButton() { AddToCartButton.Click(); }
public void ClickOnAddToShoppingCartButton() { ScrollHelper.ScrollToView(_driver, AddToCartButton); AddToCartButton.Click(); }
public void AddToCart() { AddToCartButton.ClickElement(); }
public static void PrintDashboard(CommandLineInterface _CLI) { int TotalMVTs = MVTHistory.GetMVTCount(false); int LiveMVTs = MVTHistory.GetMVTCount(true); int CompletedMVTs = TotalMVTs - LiveMVTs; int PositiveMVTs = MVTHistory.GetMVTCount(TestResultType.Positive); int NegativeMVTs = MVTHistory.GetMVTCount(TestResultType.Negative); int InconclusiveMVTs = MVTHistory.GetMVTCount(TestResultType.Inconclusive); MultiVariateTest[] LiveTests = MVTHistory.GetLiveTests(); string result = "************************** OVERALL TESTING SUMMARY *************************\n\n"; result += "Total MVTs launched: " + TotalMVTs.ToString() + " (" + CompletedMVTs.ToString() + " completed, " + LiveMVTs.ToString() + " currently live)\n"; result += "Test results:\t" + PositiveMVTs.ToString() + " Positive\t" + NegativeMVTs.ToString() + " Negative\t" + InconclusiveMVTs.ToString() + " Inconclusive (abandoned) \n\n"; if (LiveTests != null && LiveTests.Length > 0) { result += "******************************** LIVE TESTS ********************************\n"; for (int i = 0; i < LiveTests.Length; i++) { int testId = LiveTests[i].Id; TestTypesEnum type = LiveTests[i].TestType; string typeStr = ""; if (type == TestTypesEnum.ADDTOCARTBUTTON) { typeStr = "Add to Cart Btn"; } DateTime?launched = LiveTests[i].GetLaunchDateTime; int variantsNumber = LiveTests[i].GetNumberOfVariants(); MVTResult TResult = LiveTests[i].GetResult; result += "[MVT ID: " + testId.ToString() + "] [Type: " + typeStr + "] [Launch date: " + launched.ToString() + "]\n"; result += "[Variants: " + variantsNumber.ToString() + " (including control)]\n"; //Displaying ctr and test variant change details //Only "Add to cart" A/B test display supported currently. if (variantsNumber == 2 && type == TestTypesEnum.ADDTOCARTBUTTON) { AddToCartButtonVariation ctrVar = (AddToCartButtonVariation)LiveTests[i].GetVariant(0).GetVariationType(); AddToCartButtonVariation tstVar = (AddToCartButtonVariation)LiveTests[i].GetVariant(1).GetVariationType(); result += "[Control: "; if (ctrVar.colorPalette == null && ctrVar.addToCartTextCopies == null) { result += "No changes"; } else { if (ctrVar.colorPalette != null) { result += "Colour: " + ctrVar.colorPalette + " "; } if (ctrVar.addToCartTextCopies != null) { result += "Copy change: " + ctrVar.addToCartTextCopies; } } result += "]\n"; result += "[Test: "; if (tstVar.colorPalette == null && tstVar.addToCartTextCopies == null) { result += "No changes"; } else { if (tstVar.colorPalette != null) { result += "Colour: " + tstVar.colorPalette + " "; } if (tstVar.addToCartTextCopies != null) { result += "Copy change: " + tstVar.addToCartTextCopies; } } result += "]\n\n"; } //Displaying ctr and test variant visitors, cvr and stdev. Works for A/B only. if (TResult != null && variantsNumber == 2) { if (TResult.SampleSize.Length > 1 && TResult.Means.Length > 1 && TResult.ConvertedSize.Length > 1 && TResult.STDevs.Length > 1) { result += "\t[Visitors]\t[Converted]\t[%]\t[Std Dev]\n"; result += "CTRL\t" + TResult.SampleSize[0].ToString() + "\t\t" + TResult.ConvertedSize[0].ToString() + "\t\t" + TruncString((TResult.Means[0] * 100).ToString(), 4) + "%\t" + TruncString(TResult.STDevs[0].ToString(), 5) + "\n"; result += "TEST\t" + TResult.SampleSize[1].ToString() + "\t\t" + TResult.ConvertedSize[1].ToString() + "\t\t" + TruncString((TResult.Means[1] * 100).ToString(), 4) + "%\t" + TruncString(TResult.STDevs[1].ToString(), 5) + "\n\n"; result += "[T-score: " + TruncString(TResult.TScores[0].ToString(), 6) + "] " + "[Degree of freedom: " + TResult.DFree[0].ToString() + " (next known is " + TResult.NextDFree[0].ToString() + ")]\n"; result += "[Required P for next Degree of Freedom: " + TruncString(TResult.ReqPVal[0].ToString(), 6) + "]\n"; } } result += "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; } } else { //No live tests found, check if all completed. result += "\n No live tests running currently.\n"; if (AddToCartButton.IsAllVariationTested()) { result += "All the 'Add To Cart Button' type variants have been tested. The best performing variant is live on 100%."; } } _CLI.Out(result, false, false); }
public Phone AddToCart() { AddToCartButton.Click(); return(this); }
public WishListPage ClickAddToCartButton() { AddToCartButton.Click(); return(new WishListPage()); }
public static void PrintStats(CommandLineInterface _CLI) { string result = "\n\n********** MVT STATS **********\n\n"; int TotalMVTs = MVTHistory.GetMVTCount(false); int LiveMVTs = MVTHistory.GetMVTCount(true); result += "Total MVTs: " + TotalMVTs.ToString() + "\n"; result += "Live MVTs: " + LiveMVTs.ToString() + "\n"; if (LiveMVTs == 0) { result += "\n\n********** MVT STATS **********\n\n"; _CLI.Out(result, false, false); return; } MultiVariateTest[] LiveTests = MVTHistory.GetLiveTests(); if (LiveTests == null || LiveTests.Length == 0) { result += "\n\n********** MVT STATS **********\n\n"; //No live tests found, check if all completed. result += "\n No live tests running currently.\n"; if (AddToCartButton.IsAllVariationTested()) { result += "All the 'Add To Cart Button' type variants have been tested. The best performing variant is live on 100%."; } _CLI.Out(result, false, false); return; } for (int i = 0; i < LiveTests.Length; i++) { result += "\n----\n"; result += "MVT ID: " + LiveTests[i].Id.ToString() + "\n"; result += "Variant number (including control): " + LiveTests[i].GetNumberOfVariants().ToString() + "\n"; result += "Launch date: " + LiveTests[i].GetLaunchDateTime.ToString() + "\n\n"; MVTResult testResult = LiveTests[i].GetResult; if (testResult != null) { result += "Variants (including control): " + testResult.Variants.ToString() + "\n"; result += "Any variant reached significance: " + testResult.ReachedSignificance.ToString() + "\n"; result += "Visitors: "; for (int j = 0; j < testResult.Variants; j++) { result += "[" + j.ToString() + "]: " + testResult.SampleSize[j] + "\t"; } result += "\n"; result += "Converted visitors: "; for (int j = 0; j < testResult.Variants; j++) { result += "[" + j.ToString() + "]: " + testResult.ConvertedSize[j] + "\t"; } result += "\n"; result += "Means: "; for (int j = 0; j < testResult.Variants; j++) { result += "[" + j.ToString() + "]: " + testResult.Means[j] + "\t"; } result += "\n"; result += "Standard Deviations: "; for (int j = 0; j < testResult.Variants; j++) { result += "[" + j.ToString() + "]: " + testResult.STDevs[j] + "\t"; } result += "\n\n"; result += "T-Score: "; for (int j = 0; j < testResult.Variants - 1; j++) { result += "[" + j.ToString() + "]: " + testResult.TScores[j] + "\t"; } result += "\n"; result += "Degree of Freedom: "; for (int j = 0; j < testResult.Variants - 1; j++) { result += "[" + j.ToString() + "]: " + testResult.DFree[j] + "\t"; } result += "\n"; result += "Next known Degree Freedom: "; for (int j = 0; j < testResult.Variants - 1; j++) { result += "[" + j.ToString() + "]: " + testResult.NextDFree[j] + "\t"; } result += "\n"; result += "Required P for next DF: "; for (int j = 0; j < testResult.Variants - 1; j++) { result += "[" + j.ToString() + "]: " + testResult.ReqPVal[j] + "\t"; } result += "\n"; result += "Is significant: "; for (int j = 0; j < testResult.Variants - 1; j++) { result += "[" + j.ToString() + "]: " + testResult.ReachedSignificance[j] + "\t"; } result += "\n"; result += "\nNote: [0] is the control variant"; } else { result += "Results not analysed yet.\n"; } result += "\n----\n"; } result += "\n\n********** MVT STATS **********\n\n"; _CLI.Out(result, false, false); }
public void ClickBuyNowButton() { AddToCartButton.Click(); }
public void ClickAddToCartButton() { AddToCartButton.Click(); Thread.Sleep((int)ScriptWaits.SmallWait); }