Playwright button is not clickable
I had created a simple Playwright test with maker/checker, but the maker click a button does not respond to any actions/dialog pop up displayed.
This is the source code when I right click "view frame source". I don't know why cannot view page source. I generated the code using
npx playwright codegen --channel=msedge
Frame source HTML
SLQGBO_branch_maintenance_add
This is the submit button.
BranchPage.ts
import {Locator, Page, expect} from "@playwright/test";
import {randomizeInt} from '../utils/randomizeInt';
import {csvReader} from '../utils/csvReader';
import {LoginPage} from './LoginPage';
export class BranchPage {
readonly page: Page;
// Add Branch
addBtn: Locator;
constructor(page: Page) {
this.addBtn = this.page.locator('frame[name="main"]').contentFrame().locator('input#resultButton_Insert.ButtonStormyWeather'); //.getByRole('button', { name: 'Submit' }); .getByText('Submit');
}
public async clinkBranchTab() {
this.branchTab.click();
}
public async selectBranchActions(dropdownOpt: string) {
await this.cmbBox.selectOption(dropdownOpt);
}
public async addBranch(branchId: string, description: string) {
await this.addNewBtn.click();
if (branchId.length > 0) {
await this.branchId.fill(branchId);
}
if (description.length > 0) {
await this.description.fill(description);
}
await this.location.selectOption('R100');
await this.addBtn.click();
}
}
Branch.spec.ts
import {test} from "../../fixtures/roleLoginFix";
import {faker} from '@faker-js/faker';
import {BranchPage} from '../../pages/BranchPage';
test('Add Branch', {tag: '@e2e'}, async ({makerLoginFix, checkerLoginFix}) => {
// Maker login
await makerLoginFix.goto(process.env.HOMEPAGE!);
await makerLoginFix.waitForLoadState('domcontentloaded');
const makerBrchPage: BranchPage = new BranchPage(makerLoginFix);
const brchId = faker.helpers.fromRegExp('[B]{1}[0-9]{5}');
let brchDesc = faker.helpers.arrayElement(['HQ 1', 'HQ 2', 'HQ 3', 'HQ 5', 'SG Branch 1', 'SG Branch 2', 'SG Branch 3', 'SG Branch 4', 'SG Branch 5', 'SG Branch 6', 'SG Branch 7', 'SG Branch 8', 'SG Branch 9', 'SG Branch 10']);
await makerBrchPage.clinkBranchTab();
await makerLoginFix.waitForLoadState('domcontentloaded');
await makerBrchPage.selectBranchActions('/bo/bo2/branch/SLQGBO_branch_maintenance.jsp');
await makerLoginFix.waitForLoadState('domcontentloaded');
await makerBrchPage.addBranch(brchId, brchDesc);
//await makerLoginFix.locator('frame[name="main"]').contentFrame().getByRole('button', { name: 'Submit' }).click();
await makerLoginFix.waitForLoadState('domcontentloaded');
makerLoginFix.on('dialog', dialog => {
console.log(`Dialog message: ${dialog.message()}`);
dialog.accept();
});
await makerLoginFix.waitForLoadState('domcontentloaded');
// Checker Login
const checkerBrchPage: BranchPage = new BranchPage(checkerLoginFix);
await checkerLoginFix.goto(process.env.HOMEPAGE!);
await checkerLoginFix.waitForLoadState('domcontentloaded');
await checkerBrchPage.clinkBranchTab();
await checkerLoginFix.waitForLoadState('domcontentloaded');
await checkerLoginFix.waitForTimeout(2000);
await checkerBrchPage.selectBranchActions('/bo/bo2/branch/SLQGBO_branch_maintenance_checker.jsp');
await checkerLoginFix.waitForLoadState('domcontentloaded');
await checkerLoginFix.waitForTimeout(2000);
});
Please help me to resolve the error.