# 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:
 Declare a test page variable and then write AL code to open the test page by using one of the following methods:
   methods-auto/testpage/testpage-opennew-method
   methods-auto/testpage/testpage-openedit-method
   methods-auto/testpage/testpage-openview-method
 Create a PageHandler or ModalPageHandler method that has a test page parameter.
 Write AL code to trap a call to open a test page by using the methods-auto/testpage/testpage-trap-method.
> NOTE
> You must consider how you set the TransactionModel Property<properties/devenv-properties> 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 methods-auto/testpage/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 methods-auto/testfield/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 methods-auto/testpart/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.
```al
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 methods-auto/testfilter/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.
```al
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 methods-auto/testaction/testaction-invoke-method.
These are instances of the methods-auto/testaction/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 methods-auto/testpage/testpage-yes-method, methods-auto/testpage/testpage-no-method, methods-auto/testpage/testpage-ok-method and Cancel Method<methods-auto/testpage/testpage-ok-method> respectively, directly in the test page.
## Navigate among records
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:
 methods-auto/testpage/testpage-next-method
 methods-auto/testpage/testpage-previous-method
 methods-auto/testpage/testpage-first-method
 methods-auto/testpage/testpage-last-method
 methods-auto/testpage/testpage-gotorecord-method
 methods-auto/testpage/testpage-gotokey-method
 methods-auto/testpage/testpage-findfirstfield-method
 methods-auto/testpage/testpage-findnextfield-method
 methods-auto/testpage/testpage-findpreviousfield-method
## Related information
Testing the Application<devenv-testing-pages>
Test the advanced sample extension<devenv-extension-advanced-example-test>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-testing-pages, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-testing-pages/
