Editar

Compartilhar via


Test pages

You use test page objects to simulate user interactions with the application. You can:

  • View or change the value of a field on a test page.
  • View the data on page parts.
  • View or change the value of a field on a subpage.
  • Filter the data on a test page.
  • Perform any actions that are available on the page.
  • Navigate to different records.

You can create and open a test page in the following ways:

Note

You must consider how you set the TransactionModel Property to simulate the scenario that you want to test and to return the database to its initial state after the test.

Note

Test methods and code on test pages run on the Dynamics 365 Business Central Server instance, even though they simulate client interactions.

For more information about the AL methods that you use on a test page, see TestPage Data Type.

Access fields on test pages

You can access the fields on a test page by using the dot notation. For example, if you have a test page variable named CustomerCard that represents the Customer Card page, then to access the Name field on the test page, you'll write CustomerCard.Name in your code.

These fields are instances of the TestField Data Type, so you can use the corresponding AL methods to work with them. For example, if you have a test page variable named CustomerCard that represents the Customer Card page, then to assign the value of the No. field to a variable named CustNo, you write CustNo := CustomerCard."No.".Value in your code. To write a value in the Address field of a Customer Card page, you write CustomerCard.Address.Value := '<address>' in your code.

Access page parts and subpages

You access page parts and subpages on a test page by using the dot notation.

These are instances of the TestPart Data Type, so you can use the corresponding AL methods to work with them.

For example, to compare the value of the No. field on a page to the value of the No. field on a FactBox on the page, you can write the following code.

if CustomerCard."No.".Value <> CustomerCard."Sales Hist. Sell-to FactBox"."No.".Value then  
  error("Page part data is not updated.");  
  

Filter data on test pages

To filter the data that can be accessed on a test page, you use AL methods corresponding to the TestFilter Data Type instances. For example, to filter the customers on the Customer List page based on a range of values in the No. field, you can write the following code.

CustomerList.Filter.SetFilter("No.", '20000..30000');  

Invoke actions on test pages

Any action that is available on a page is also available on the test page that mimics the original page. You access page actions by using the dot notation and the Invoke Method.

These are instances of the TestAction Data Type, so you can use the corresponding AL methods to work with them. To access built-in actions, such as Yes, No, OK, or Cancel you can also call the Yes Method, No Method, Ok Method and Cancel Method respectively, directly in the test page.

To simulate moving to different items on a list page or to different records on a card page, you can use one of the following navigation methods:

See Also

Testing the Application
Test the advanced sample extension