public static ClientLogicalForm OpenPage(TestContext testContext, UserContext context, int pageId) { ClientLogicalForm form; using (new TestTransaction(testContext, String.Format("OpenPage{0}", pageId))) { form = context.OpenForm(pageId.ToString(CultureInfo.InvariantCulture)); context.EnsurePage(pageId, form); } DelayTiming.SleepDelay(DelayTiming.OpenFormDelay); return form; }
private ClientLogicalForm CreateNewPurchaseInvoice(UserContext userContext) { // Invoke using the Purchase Invoice action on Role Center and catch the new page var newPurchaseInvoicePage = userContext.EnsurePage( MiniPurchaseInvoiceCard, userContext.RoleCenterPage.Action("Purchase Invoice") .InvokeCatchForm()); var vendorName = TestScenario.SelectRandomRecordFromListPage( TestContext, userContext, MiniVendorList, "Name"); TestScenario.SaveValueAndIgnoreWarning( TestContext, userContext, newPurchaseInvoicePage.Control("Vendor Name"), vendorName); var vendorInvoiceNo = SafeRandom.GetRandomNext(100000, 999999); TestScenario.SaveValueWithDelay( newPurchaseInvoicePage.Control("Vendor Invoice No."), vendorInvoiceNo); // Add a random number of lines between 2 and 15 var noOfLines = SafeRandom.GetRandomNext(2, 15); for (var line = 0; line < noOfLines; line++) { AddPurchaseInvoiceLine(userContext, newPurchaseInvoicePage, line); } userContext.ValidateForm(newPurchaseInvoicePage); TestContext.WriteLine( "Created Purchase Invoice {0}", newPurchaseInvoicePage.Caption); return newPurchaseInvoicePage; }
private void PostPurchaseInvoice( UserContext userContext, ClientLogicalForm purchaseInvoicePage) { ClientLogicalForm openPostedInvoiceDialog; using (new TestTransaction(TestContext, "Post")) { var postConfirmationDialog = purchaseInvoicePage.Action("Post") .InvokeCatchDialog(); if (postConfirmationDialog == null) { userContext.ValidateForm(purchaseInvoicePage); Assert.Fail("Confirm Post dialog not found"); } openPostedInvoiceDialog = postConfirmationDialog.Action("Yes") .InvokeCatchDialog(); } if (openPostedInvoiceDialog == null) { Assert.Fail("Open Posted Invoice dialog not found"); } ClientLogicalForm postedPurchaseInvoicePage; using (new TestTransaction(TestContext, "OpenPostedPurchaseInvoice")) { postedPurchaseInvoicePage = userContext.EnsurePage( PostedPurchaseInvoiceCard, openPostedInvoiceDialog.Action("Yes").InvokeCatchForm()); } TestContext.WriteLine( "Posted Purchase Invoice {0}", postedPurchaseInvoicePage.Caption); TestScenario.ClosePage( TestContext, userContext, postedPurchaseInvoicePage); }
public void RunCreateAndPostSalesOrder(UserContext userContext) { // Invoke using the new sales order action on Role Center var newSalesOrderPage = userContext.EnsurePage(SalesOrderPageId, userContext.RoleCenterPage.Action("Sales Order").InvokeCatchForm()); // Start in the No. field newSalesOrderPage.Control("No.").Activate(); // Navigate to Sell-to Customer No. field in order to create record var sellToCustControl = newSalesOrderPage.Control("Sell-to Customer No."); sellToCustControl.Activate(); // select a random customer from Sell-to Customer No. lookup var custNo = TestScenario.SelectRandomRecordFromLookup(TestContext, userContext, sellToCustControl, "No."); // Set Sell-to Customer No. to a Random Customer and ignore any credit warning TestScenario.SaveValueAndIgnoreWarning(TestContext, userContext, sellToCustControl, custNo); TestScenario.SaveValueWithDelay(newSalesOrderPage.Control("External Document No."), custNo); var newSalesOrderNo = newSalesOrderPage.Control("No.").StringValue; userContext.ValidateForm(newSalesOrderPage); TestContext.WriteLine("Created Sales Order No. {0} for Cust No. {1}", newSalesOrderNo, custNo); // Add a random number of lines between 2 and 25 var noOfLines = SafeRandom.GetRandomNext(2, 25); for (var line = 0; line < noOfLines; line++) { AddSalesOrderLine(userContext, newSalesOrderPage, line); } // Check Validation errors userContext.ValidateForm(newSalesOrderPage); // Post the order PostSalesOrder(userContext, newSalesOrderPage); // Close the page TestScenario.ClosePage(TestContext, userContext, newSalesOrderPage); }