module.exports = new HomePage();Calling methods to be used in the test
The module.exports
statement is used to export an instance of each page class as a module:
module.exports = new HomePage(); module.exports = new loginPage();
// TestName.ts
The TestName
test file utilizes the exported instances of the page classes. In this example test case, we interact with the LoginPage and the HomePage web pages using the methods and objects defined in the respective page classes:
import LoginPage from('../PageObjects/LoginPage'); import HomePage from('../PageObjects/HomePage'); import assert from('assert'); describe('Test Name', () => { before(() => { // Set up WebDriverIO configuration }); it('should perform login and logout', () => { LoginPage.enterUsername('username'); LoginPage.enterPassword('password'); ...