Skip to content

Instantly share code, notes, and snippets.

@svierk
Last active July 14, 2023 02:08
Show Gist options
  • Save svierk/8616ff0544913025c0b6445218d1444e to your computer and use it in GitHub Desktop.
Save svierk/8616ff0544913025c0b6445218d1444e to your computer and use it in GitHub Desktop.
UTAM test for the creation of an account record in Salesforce
import ObjectHomeDesktop from 'salesforce-pageobjects/force/pageobjects/objectHome';
import RecordActionWrapper from 'salesforce-pageobjects/global/pageobjects/recordActionWrapper';
import RecordHomeTemplateDesktop from 'salesforce-pageobjects/global/pageobjects/recordHomeTemplateDesktop';
import FormattedText from 'salesforce-pageobjects/lightning/pageobjects/formattedText';
import DesktopLayoutContainer from 'salesforce-pageobjects/navex/pageobjects/desktopLayoutContainer';
import { logInSalesforce } from './utam-helper';
describe('utam-examples', () => {
beforeEach(async () => {
await logInSalesforce();
});
it('create an account', async () => {
// navigate to the app launcher
const container = await utam.load(DesktopLayoutContainer);
const appNav = await container.getAppNav();
// select the navigation bar of the current app
const appNavBar = await appNav.getAppNavBar();
// select and click the accounts tab
const tab = await appNavBar.getNavItem('Accounts');
await tab.clickAndWaitForUrl('lightning/o/Account/list?filterName=Recent');
// select current list view
const listView = await (await utam.load(ObjectHomeDesktop)).getListView();
const listViewHeader = await listView.getHeader();
// click on new account action
await (await listViewHeader.waitForAction('New')).click();
// select account name input and enter name
const modal = await utam.load(RecordActionWrapper);
const recordForm = await modal.getRecordForm();
const input = await (await (await recordForm.getRecordLayout()).getItem(1, 2, 1)).getTextInput();
await input.setText('UTAM Test');
// click modal save button
await recordForm.clickFooterButton('Save');
await modal.waitForAbsence();
// select highlight panel to get record details
const recordHome = await utam.load(RecordHomeTemplateDesktop);
const highlights = await (await (await recordHome.getHighlights()).getRecordLayout()).waitForHighlights2();
const formattedText = await highlights.getPrimaryFieldContent(FormattedText);
// assert the account name in highlights panel matches the just created account
expect(await formattedText.getInnerText()).toContain('UTAM Test');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment