Use the following code as a basis for a new test file:
import {test} from '../../tests/fixtures/serverless/basePage';
test.beforeEach(async ({ sideNav }) => {
await sideNav.goto();
await sideNav.<test section>;
});
test('<test name>', async ({page, <fixtures>}) => {
await test.step('<step name>', async () => {
// Put your code here
await <page>.<method>;
await <page>.<method>;
});
});
test('<test name>', async ({page, <fixtures>}) => {
await test.step('<step name>', async () => {
// Put your code here
await <page>.<method>;
await <page>.<method>;
});
});
Tip | |
---|---|
<test section> |
Navigation method to a target section. Example: clickInfrastructure(); |
<fixtures> |
Pages/components that you're going to use. Example: { datePicker, sideNav, discoverPage, page, servicesPage } Note: page is always required. |
<step name> |
In a test report, <step name> is used as a property of the step duration: "step01": 4351 , hence apply JSON property name format here.Example: step01 |
<page>.<method> |
Specify target page and desired action separated by a dot. Use this section to check what methods are available for the specified page/component. Example: await discoverPage.clickLogsExplorerTab(); await discoverPage.assertVisibilityCanvas(); await discoverPage.assertVisibilityDataGridRow(); Some methods require passing a parameter: assertVisibilityVisualization(string) For example, you might need to pass a visualization name: assertVisibilityVisualization('infraAssetDetailsKPIcpuUsage') If a method is used repeatedly across the test, it is recommended adding a variable for the value: const cpuUsage = 'infraAssetDetailsKPIcpuUsage'; await infrastructurePage.assertVisibilityVisualization(cpuUsage); |
General tip:
Make tests as isolated as possible
Each test should be completely isolated from another test and should run independently with its own local storage, session storage, data, cookies etc. Test isolation improves reproducibility, makes debugging easier and prevents cascading test failures.
dashboardPage
Actions |
---|
clickOptions() |
clickTags() |
closeFlyout() |
filterByKubernetesTag() |
kubernetesVisualizationOptions(string) |
logQuery() |
logQueryTime(string) |
logRequestTime(string) |
openRequestsView() |
queryToClipboard() |
Assertions |
---|
assertVisibilityHeading() |
assertVisibilityTable() |
assertVisibilityVisualization(string) |
datePicker
Actions |
---|
clickApplyButton() |
clickDatePicker() |
fillTimeValue(string) |
selectDate() |
selectTimeUnit(string) |
Assertions |
---|
assertVisibilityDatePicker() |
assertSelectedDate() |
dependenciesPage
Actions |
---|
clickInvestigateButton() |
clickTableRow() |
clickTimelineTransaction() |
clickTraceLogsButton() |
openOperationsTab() |
Assertions |
---|
assertVisibilityTable() |
assertVisibilityTabPanel() |
assertVisibilityTimelineTransaction() |
infrastructurePage
Actions |
---|
clickDismiss() |
clickNodeWaffleContainer() |
clickPopoverK8sMetrics() |
clickTableCell() |
closeFlyout() |
closeInfraAssetDetailsFlyout() |
hostsVisualizationOptions(string) |
logQuery() |
openHostsLogs() |
openRequestsView() |
queryToClipboard() |
searchErrors() |
sortByMetricValue() |
switchInventoryToPodsView() |
switchToTableView() |
Assertions |
---|
assertVisibilityPodVisualization(string) |
assertVisibilityVisualization(string) |
sideNav
Actions |
---|
clickDiscover() |
clickDashboards() |
clickApplications() |
clickServices() |
clickTraces() |
clickDependencies() |
clickInfrastructure() |
clickInventory() |
clickHosts |
clickSettings() |
clickManagement() |
clickFleet() |
discoverPage
Actions |
---|
clickLogsExplorerTab() |
expandLogsDataGridRow() |
filterByNginxAccess() |
filterLogsByError() |
Assertions |
---|
assertVisibilityCanvas() |
assertVisibilityDataGridRow() |
assertVisibilityDocViewer() |
assertVisibilityFlyoutLogMessage() |
assertVisibilityFlyoutService() |
servicesPage
Actions |
---|
clickInvestigate() |
clickHostLogsButton() |
filterByCorrelationValue() |
filterByFieldValue() |
openFailedTransactionCorrelationsTab() |
openTransactionsTab() |
selectMostImpactfulTransaction() |
selectServiceOpbeansGo() |
Assertions |
---|
assertVisibilityCorrelationButton() |
assertVisibilityErrorDistributionChart() |
assertVisibilityVisualization(string) |
Check if there's a locator to UI element you need to interact with among available for that page. If there's not, add a new one using the following template:
<locatorFunction> = () => this.page.<locator>;
Tip | |
---|---|
<locatorFunction> |
Example:logsExplorerTab |
<locator> |
Specify a locator to UI element. Check this guide on locating elements. Examples: getByTestId('logExplorerTab') locator('xpath=//canvas[contains(@class, "echCanvasRenderer")]') getByRole('link', { name: 'Traces' }) |
Now create a method using that locator(s).
public async <methodName>(<parameters>) {
await this.<locatorFunction>.<action>;
}
Tip | |
---|---|
<methodName> |
Example:expandLogsDataGridRow() |
<parameters> |
Example:assertVisibilityPodVisualization(title: string) |
<locatorFunction> |
Specify a locator function. Examples: logsExplorerTab() |
<action> |
Specify an action to perform against a locator. See this page to check available actions. Examples: click() fill('error') |