Acumatica Test Framework In Acumatica Part 2 Practice

Acumatica Test Framework in Acumatica. Part 2 (Practice)

In this part we implement real automation test for creating POOrder - screen PO301000;

Before to start, please read first part of rhis post. 

The main steps:

  1. Create solution and add nedeed components from SDK folder
  2. Add new project (Net library) to solution 
  3. Configure generator and run it for create .cs class with all components on screen PO301000
  4. Add POOrder.cs and describe some methods for test
  5. Add the main class (for example F100_Part1_Lesson1.cs) where we describe Execute() method
  6. Run solution, view result of test

       Create solution and add nedeed components from SDK folder

CCreate a test solution by using Visual Studio 2017 as follows:

  1. In Visual Studio 2017, create a new project TestSDKProject with the following parameters:
  2. Project template: Visual C#
  3. Framework version: .NET Framework 4.7
  4. Project type: Console Application
  5. Project name: TestSDKProject
  6. Solution name: TestSDKProject

 Include references to the following binary libraries (located in the TestProject subfolder of your Test SDK package) in the TestProject project: Execution.dll

At this point your solution should look like shown on the screenshot below:

 As you can see, I also add TestAcumatica.dll.

So create this project.

Add new project (Net library) to solution 

Add a new project TestAcumatica to the created solution with the following parameters:

Project template: Visual C#

Framework version: .NET Framework 4.7

Project type: Class Library

Project name: TestAcumatica

 Project name must start from the word Test

Include references to the following binary libraries (located in the TestProject subfolder of your Test SDK package) in the TestAcumatica project:

PX.QA.Tools.dll

Core.dll

WebDriver.dll

WebDriver.Support.dll

As you can see WebDriver.dll and WebDriver.Support.dll it is selenium web driver ( and you not need to dowload slelenium)

At this point your solution should look like shown on the screenshot below:

Do not forget include reference to the TestAcumatica project in the TestSDKProject project.

Open Program.cs file of the TestProject project (or create a new one if it was not created automatically on step 1) and modify it as follows:

public class Program
    {
        static int Main(string[] args)
        {
            return Execution.Launcher.Main(args);
        }
    }

Configure generator and run it for create .cs class with all components on screen PO301000

Open the ClassGenerator.exe.config file, which is located in the ClassGenerator folder of your Test SDK package, and modify it as follows:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <appSettings>
 <!--Local path to the Acumatica ERP instance installation directory-->
 <add key="SitePhysicalPath" value="C:\Program Files (x86)\Acumatica ERP\AcumaticaDBTest"/>
 <!--Output directory to store the generated page wrappers-->
 <add key="GenResultPath" value="C:\share\output"/>
 <!--User to be used for page wrapper generation-->
 <add key="UserName" value="admin@Demo"/>
 <!--IDs of the pages you want to run wrapper generation for; the wildcard * is supported-->
 <add key="FileNameFilter" value="PO301000"/>
 <!--Deletes all files in output directory before running the page wrapper generation process-->
 <add key="ClearOutput" value="true"/>
 <!--Namespace where wrapper classes will be defined. Use the template "GeneratedWrappers.<PartnerName>".-->
 <add key="Namespace" value="GeneratedWrappers.Acumatica"/>
 </appSettings>
</configuration>

If you have more than 1 visible companies in the application instance always specify the company name, e.g.: ; Company name is not required if you have only 1 visible company in the application instance, e.g.

In my situation I have created company - Demo;

After go to your download SDK project - ClassGenerator - and run ClassGenerator.exe

If all will be correct you can see input text - Process DONE - PO301000, and in folder you can see:

After it add folder - Wrappers to TestAcummatica project, and add this PO301000_POOrderEntry.cs file;

What is wrappers?

The page wrapper generation tool creates object mapping model for every page developed by Acumatica Framework. You can access any UI element such as Forms, Grids, Toolbars, data-fields available on a page which you use operating as an ordinary user with Acumatica ERP or any othe Acumatica based product. Test SDK uses built-in control wrapper to construct complex objects such as forms, grids and pages. You need to create wrappers for each page that you want to test.

And for this you use - page wrapper generation tool: You use this tool to create wrappers for the pages of your Acumatica-based product. 

    Add POOrder.cs and describe some methods for test

In this step, you will include extension classes for page wrappers generated earlier into project.

To include extension classes for page wrappers generated earlier into project, do the following:

  1. Create an Extensions folder in the TestAcumatica projec.
  2. 2. Include extension class for generated page wrappers: (just add new POOrder.cs)

public class POOrder : PO301000_POOrderEntry
    {
        public POOrder()
        {
            ToolBar.Save.WaitAction = Wait.WaitForPageToLoad;
        }
 
        public c_document_form Summary
        {
            get
            {
                return base.Document_form;
            }
        }
       public c_transactions_grid Details
        {
            get
            {
                return base.Transactions_grid;
            }
        }
    }

So here we describe constructot for load PO301000 page;

Also Summary and Details - what is it?

And this methods described, generated in PO301000_POOrderEntry (c_document_form, c_transaction_grid) and we return this elements;

Add the main class (for example F100_Part1_Lesson1.cs) where we describe Execute() method

So create F100_Part1_Lesso1.cs and add to Testcumatica project:

public class F100_Part1_Lesson1 : Check
   {
 
       public override void BeforeExecute()
       {
           using (TestExecution.CreateTestCaseGroup("Preparation"))
           {
               using (TestExecution.CreateTestStepGroup("Sign in"))
               {
                   Browser.StartingUrl = Config.SITE_DST_URL;
                   PxLogin LoginPage = new PxLogin();
                   LoginPage.Username.Type(Config.SITE_DST_LOGIN);
                   LoginPage.Password.Type(Config.SITE_DST_PASSWORD);
                   LoginPage.CompanyId.SelectValue("Demo");
                   LoginPage.SignIn.Click();
               }
         
               using (TestExecution.CreateTestStepGroup("Testing: Poorders"))
               {
                   POOrder poOrder = new POOrder();
                   poOrder.OpenScreen();
                   poOrder.Insert();
                   poOrder.Summary.OrderType.Select("Normal");
                   poOrder.Summary.VendorID.Type("BETAAIR");
                   poOrder.Summary.VendorRefNbr.Type("TEST Vendor REF");
                   poOrder.Details.ToolBar.New.Click();               
                   poOrder.Details.Row.BranchID.Type("HQ");
                   poOrder.Details.Row.InventoryID.Select("CARRENT");
                   poOrder.Details.Row.OrderQty.Type("100");
                   poOrder.Details.Row.CuryUnitCost.Type("20");
                   poOrder.Details.Row.ProjectID.Type("INTERNAL18");
                   poOrder.Details.Row.TaskID.Type("01OPS");
 
                   poOrder.Save();
               }
 
               
               }
           }
       }
 
       //Lesson 1: Introduction to General Ledger.
       //Add test-specific logic in this method.
       public override void Execute()
       {
           
}        //This method executes after the test.        public override void AfterExecute()        {                   }    }

Ok, in BeforeExecute() I described my test for creating POOrder, you can do it in Execute() method of course, now it is no matter)

And we ready to run this test.

Run solution, view result of test

You can run test in Chrome or Firefox browser,  in this case I use Firefox.

Fot it - Modify RunnerExample.xml located in Test SDK package as follows:

<?xml version="1.0" encoding="utf-8"?>
<config>
 <general>
 <browser>*firefox</browser>
 <browserbin>C:\Users\xarec\Downloads\TestSDK_17_209_0028_21\Firefox\firefox.exe</browserbin>
 <browser_downloads_folder>c:\share\download\</browser_downloads_folder>
 <site_dst>
 <url>http://localhost/AcumaticaDBTest</url>
 <login>admin</login>
 <pswd>Qwerty!123</pswd>
 </site_dst>
 <logging>
 <logStorage type="htmlfile" level="INFO" outputFolder="c:\share\logStorage" screenshotActive="true" />
 </logging>
 </general>
 <testing>
 <Check Name="F100_Part1_Lesson1"/>
 </testing>
</config>

After click rigth button on TestSDKProject, choose properties and go to Debug and past your path to RunnerExample in Command Line Arguments:

/TestSDKProject.exe

/config "C:\Users\xarec\Downloads\TestSDK_17_209_0028_21\RunnerExample.xml"

Build solution and click Start. If all configure ok, you will see that Firefox will open, open Acumatica, sign in, and create a new POOrder:

After you can go to share - logStorage and will see the result:

So here we can see that all ok, if some operation executed ok, so it will be black color and screensot

POOrder is save. But what will be, if we describe not correct data, or something not correct?

In the LOG we can view it, color will be read.

That`s all for first meet with Acumatica Test Framework, thank you for reading:)

8 Comments

  • Diva said

    Hi yuriy I have a question

    I'm try create PO301000_POOrderEntry.cs file but I can't it, I don't know that I did bad :(

    Can you help me?

  • Diva said

    Hi, me again

    well, I try this example but....


    I do not know what happened that my instance it have next error


    Server Error in '/rembolso' Application.
    Access is denied.
    Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

    Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0

    :( Can you help me? :(

  • docotor said

    Do you can open your instance at manually in browser?

  • Diva said



    Hi, I can't

    I not finish my test yet,I think this causes the error.

    Actually but I can see the file PO301000_POOrderEntry.cs, the test finally created it I did not finish processing the program when I wrote you.

    but I was want open my instance in browser and showed me this error...

  • Diva said

    Excuse me but, I have another error. LOL

    I did modify my Runner Example.xml but when I want run my app. It show me this error

    core.exceptions.ExecitionException: The /config parameter is not specified

    en Exection.Laucher.Main(String[] args) en E:\Bld\AC-TESTSDK2018R109-JOB1\test\Selenium\Execution\Launcher.cs linea a 33

    But I don't get it, if Exection is an DLL

  • docotor said

    Sorry, but for me is a bit hard to follow you and what issue you are facing.

  • Diva said

    I'm sorry, I know there are many problems :(

    but my first problem is solved, I mean I cant see PO301000_POOrderEntry.cs file created by ClassGenerator.exe

    So I try the step "Run solution, view result of test" but when modify my RunnerExample.xml file I have this error:

    core.exceptions.ExecitionException: The /config parameter is not specified

    en Exection.Laucher.Main(String[] args) en E:\Bld\AC-TESTSDK2018R109-JOB1\test\Selenium\Execution\Launcher.cs

    Too my instance say Access deneged and I can't run it manually in browser :(

  • docotor said

    Such testings should be done initially in your local instance, and then applied to your instance to which you don't have access.

Add a Comment
Comments are closed