import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch({ channel: 'chrome', headless: false }); const context = await browser.newContext(); const page = await context.newPage(); await page.goto('https://trvoa-usa.inruan.com/login.html'); await page.getByRole('textbox', { name: '用户名:' }).click(); await page.getByRole('textbox', { name: '用户名:' }).fill('testir888'); await page.getByRole('textbox', { name: '密码:' }).click(); await page.getByRole('textbox', { name: '密码:' }).fill('testir888'); await page.getByText('登录').click(); await page.getByText('总计划模块').click(); await page.getByRole('link', { name: '创建总计划' }).click(); await page.locator('iframe').nth(1).contentFrame().locator('.textbox.textbox-invalid > .textbox-addon > .textbox-icon').first().click(); await page.locator('iframe').nth(1).contentFrame().getByText('trvoa1').click(); await page.locator('iframe').nth(1).contentFrame().locator('.tr-of-operator > td:nth-child(2) > .textbox.combo > .textbox-text').click(); await page.locator('iframe').nth(1).contentFrame().locator('.textbox.combo.textbox-focused > .textbox-addon > .textbox-icon').click(); await page.locator('iframe').nth(1).contentFrame().getByText('JOY').click(); await page.locator('iframe').nth(1).contentFrame().locator('.tr-of-manager > td:nth-child(2) > .textbox.combo > .textbox-addon > .textbox-icon').click(); await page.locator('iframe').nth(1).contentFrame().getByText('IT测试').click(); await page.locator('iframe').nth(1).contentFrame().getByRole('link', { name: '保存' }).nth(1).click(); await page.locator('iframe').nth(1).contentFrame().locator('.textbox.textbox-invalid > .textbox-addon > .textbox-icon').click(); await page.locator('iframe').nth(1).contentFrame().getByText('北京竹园2[bjzy]').click(); await page.locator('iframe').nth(1).contentFrame().getByRole('link', { name: '保存' }).nth(1).click(); await page.locator('iframe').nth(1).contentFrame().getByRole('link', { name: '确定' }).click(); // --------------------- await context.close(); await browser.close(); })();